
Programming the RCX • Chapter 6 107
■
Input port 1 is attached to a touch sensor connected to the bumper. It
closes (goes from 0 to 1) when the bumper is pressed.
■
Input port 2 is attached to a face-down light sensor that reads the line.
Here is the initial code you should write:
int floor,line;
task Main()
{
Initialize();
Calibrate();
Go_Straight();
while(true)
{
Check_Bumper();
Follow_Line();
}
}
The main level of your program is quite simple, because at this point you’re
not concerned with what Go_Straight or the other subroutines mean in terms
of actions, you’re only concerned with the logic that connects the different situa-
tions.You are deciding the rules ...