Program Review: Wait for Green
- The program shown below is sample code for making your robot wait until it sees the color green.
Wait Block
Color Sensor - Compare - Color
Stops the program from processing additional commands until the Color Sensor value is '3' (Green)
Robot waits for a Green signal before continuing the program.
Move Steering Block
On for Rotations
Moves the robot forward. Note that the program can only reach this block after the "Wait for Color" block finishes.
Moves forward (after Wait Block finishes)
Program Review: Wait for No Red
- The program shown below is sample code for the RailRoad Crossing mini-challenge.
Wait Block
Color Sensor - Compare - Color
Stops the program from processing additional commands until the Color Sensor value is '0' (No Color)
Robot waits for the red signal to go away before continuing the program.
Move Steering Block
On for Rotations
Moves the robot forward. Note that the program can only reach this block after the "Wait for Color" block finishes.
Moves forward (after Wait Block finishes)
Program Review: Forward to Stop Line
- The program shown below is sample code for 'Forward to Stop Line' mini-challenge.
The program assumes that the robot is running on a white table, looking for a black line.
- First, the robot starts its motor to move forward, and when the color sensor sees the color black,
the robot stops the motor.
Move Steering Block
On
Turns Motors B+C On at 50% Power
Starts moving the robot forward. Another Move or Motor command will need to stop them later.
Wait Block
Color Sensor - Compare - Color
Stops the program from processing additional commands until the Color Sensor value is '1' (color black)
Robot waits until the Color Sensor sees the color black before continuing the program.
Move Steering Block
Off
Turns Motors B+C Off, and sets them to a Braking state
Stops the robot. Note that the program can only reach this block after the "Wait for Color" block finishes.