Page 172 -
P. 172
243_masterpieces_03.qxd 4/18/03 7:02 PM Page 144
144 Masterpiece 3 • The LEGO Turning Machine
while (SENSOR_2 < TOUCH_HIGH_THRESHOLD) {};
while (SENSOR_2 > TOUCH_LOW_THRESHOLD) {};
Off(OUT_A);
}
void move_left()
{
// run motor until the touch sensor engages a new peg
OnRev(OUT_A);
while (SENSOR_2 < TOUCH_HIGH_THRESHOLD) {};
while (SENSOR_2 > TOUCH_LOW_THRESHOLD) {};
Off(OUT_A);
}
Note that when looking at the machine with the RCX close to you, which is sup-
posed to be the front side, if you run the move_right procedure, the tape actually move
leftward, and vice versa! This may sound a bit confusing, but in the original machine
designed by Alan Turing, what is actually moving is the head, and not the tape.Therefore,
we’ve kept the concept that “move right” means “move one cell to the right.”
As you’ve seen, the Tape sub-assembly is built with multiple cells that contain two
adjacent yellow liftarms as a switch. We choose to consider that if the liftarm is “down”
(touching the worm gears), the cell is empty; if it is “up,” the cell contains a symbol.
Using the up and down switches, we can control the writing and erasing of the cells on
the tape.A very short impulse to the motor is enough to let the liftarms pass from one
side to the other.Another short impulse in the opposite direction resets the small arm
(axle) to its original position.
void write()
{
OnRev(OUT_C);
Wait(5);
OnFwd(OUT_C);
Wait(5);
Off(OUT_C);
}
void erase()
{
OnFwd(OUT_B);
Wait(5);
OnRev(OUT_B);
Wait(5);
Off(OUT_B);
}

