Program Design - What Must The Controller Do?

One of the hardest and most important parts of creating a computer program is determining exactly what the program must do. This might sound strange, but think a moment: if you don't know exactly what a program must do, how do you write the program?

In order to figure what it should do, first refresh your memory of What Can A Controller Do In Your Haunt.

Your knowledge of what a controller can do is your "toolkit" of things you can do inside the controller program. Now it is time to string these capabilities together into a list of things that the controller should do with the prop.

When people have to write programs for a living, they usually start by trying to define the "requirements" of what the program has to do. There are a lot of different methods that can be used to do that. We will just make a simple list of things that the controller program must do.

skip list of on-page links

List The Things The Prop Must Do

Just write the list of desirable activities, in the order in which they should occur:
  1. wait for the Trick-or-Treater
  2. pop up the monster
  3. after the monster pops up, make it roar
  4. show the monster for 5 seconds
  5. hide the monster again
  6. do not trigger again until the current kid leaves
That's not a bad start!

Check It Once

Now, look at the list and mull it over. Is that exactly what you want the automated prop to do? Ask yourself: Chances are good that you'll think of more stuff to add to the list.

What does it really mean to "wait for the Trick-or-Treater"? How long does it take for the monster to pop out? There is a strobe light in the room that can simulate a lightning flash - trigger it for every third appearance of the monster.

So, let's refine the sequence a little. The final sequence is:

  1. wait for the Trick-or-Treater
    • detect the kid's presence by looking at the input from a Passive Infrared (PIR) detector
    • to be sure that the kid is really there, make sure the "kid present" input lasts for a full second before acting on it
  2. pop up the monster
    • it takes 1 second for the monster to get all the way up
  3. after the monster pops up, make it roar
  4. every third appearance of the monster should be accompanied by a flash of lightning
  5. show the monster for 5 seconds
  6. hide the monster again
  7. do not trigger again until the current kid leaves
    • detect the kid's presence by looking at the input from a Passive Infrared (PIR) detector
    • to be sure that the kid is really gone, make sure the "nobody there" input lasts for a full 5 seconds before acting on it

Check It Twice

Is that really final? Look it over again. Pretend you are going to buy one of these - after paying for it, if it did exactlywhat the list says, would you be happy? Pretend that you are writing a legal contract, and you need to spell out all the fine details.

What do you do when it's all over? Does the flash of lightning need thunder to go with it? How do we make the roar and thunder sounds?

So, the latest final sequence is:

  1. wait for the Trick-or-Treater
    • detect the kid's presence by looking at the input from a Passive Infrared (PIR) detector
    • to be sure that the kid is really there, make sure the "kid present" input lasts for a full second before acting on it
  2. pop up the monster
    • it takes 1 second for the monster to get all the way up
  3. after the monster is all the way up, make it roar
    • roar is played by a digital sound chip; just send it a pulse to make it play
  4. every third appearance of the monster should be accompanied by a flash of lightning
    • also trigger thunder on a digital sound chip; just send it a pulse to make it play
  5. show the monster for 5 seconds
  6. hide the monster again
  7. do not trigger again until the current kid leaves
    • detect the kid's presence by looking at the input from a Passive Infrared (PIR) detector
    • to be sure that the kid is really gone, make sure the "nobody there" input lasts for a full 5 seconds before acting on it
  8. start again at the top

Are You Done?

If you look closely, you can see that some details are still missing.

How about those sound chips that say, "just send it a pulse to make it play"? Is the pulse from 0 to 1, back to 0? Or is it 1 to 0, back to 1? And how long must the pulse last?

My point is that it often takes a long time to figure out exactly what the program must do. It takes several cycles of "I think that's it" and "I just figured out some more!"

Just do the best that you can, and be willing to learn more about what the program must do after you start writing it. You can add new requirements for the program at any time - even after the prop has been in use for months. But the earlier that you know about the requirements, the easier it will be to write the program to satisfy them.

Related Pages

Skip this list.
Our series on programming controllers:
privacy policy | write to us | tip us
©Copyright 2006 by The Wolfstone Group. All rights reserved.
You must read and abide by our terms of service.