Programming for sensor input: To have a program act on incoming sensor input, the program must have a way of monitoring the incoming information. For example, if a program is set to run one way if a touch sensor is pressed and another way if it’s not, then the program must have a way of checking whether or not the sensor is pressed.

RCX Code offers several ways to obtain sensor input, using Stack Decision Makers and Sensor Watchers.

 

Stack Decision Makers The Robotics Invention System places blocks that monitor incoming sensor information in several bins—Wait, Repeat, Yes or No, and Sensors. Since our activities are organized around kinds of sensors rather than around kinds of blocks, we’ve decided to cluster all sensor blocks that can be embedded in a stack into one group that we called Stack Decision Makers. These include the Wait Until, Repeat While, Repeat Until, and the Yes or No blocks. We called them Stack Decision Makers: Stack because they are always part of a stack, and Decision Makers because when it’s their turn to execute, the program has a decision to make—to wait, to execute one branch or another, or to continue to do what it has been doing.

Stack Decision Makers make a program branch, repeat actions, or wait for input. These include the Yes or No block for branching, the Repeat While and Repeat Until for repeating a set of commands based on sensor input, and the Wait Until block for having a program wait until a certain condition is met and then executing the commands that fall under it.

 

Sensor Watchers also check for sensor input, but they are not embedded in a stack of commands. They are connected to the program at the top level (to the program block). At this level, Sensor Watchers monitor the sensors all the time (with preset intervals), checking for input repeatedly, while other parts of the program continue to run. With Sensor Watchers, a program can monitor up to 9 stacks, each with its own watcher.

 

Close Window