- :-

Program Review: Wait for Touch

  • The program shown below is a sample code for making your robot wait until touch sensor is pressed.
Hover on any block in the program to view a detailed explanation.
Wait Block Touch Sensor - Compare - State Stops the program from processing additional commands until the Touch Sensor value is '1' (Pressed) Robot waits until the Touch Sensor is pressed 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 Touch" block finishes. Moves forward (after Wait Block finishes)

Program Review: Forward until Touch

  • The program shown below is a sample code for 'Forward until Touch' movement. The robot first starts its motor to move forward, and when the touch sensor is pressed, the robot stops the motor.
Hover on any block in the program to view a detailed explanation.
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 Touch Sensor - Compare - State Stops the program from processing additional commands until the Touch Sensor value is '1' (Pressed) Robot waits until the Touch Sensor is pressed 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 Touch" block finishes.

Program Review: Vacuum Challenge

  • The program shown below is a sample solution to the Vacuum Mini-Challenge.
  • The solution reuses a four-block pattern, marked as "Behavior Pattern" below. In the pattern, the robot moves forward until it touches the wall, then backs up and turns 90 degrees to face the next wall. Since this behavior works for all four walls of the room, the program simply copy-pastes that pattern three more times.
Hover on any block in the program to view a detailed explanation.
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 Touch Sensor - Compare - State Stops the program from processing additional commands until the Touch Sensor value is '1' (Pressed) Robot waits until the Touch Sensor is pressed before continuing the program.
Move Steering Block On for Rotations Moves the robot backward 0.5 rotations at 50% power. Backs up from the wall. Note that the program can only reach this block after the "Wait for Touch" block finishes.
Move Steering Block On for Rotations Turns in place to the left, for 0.5 rotations (approx. 90 degrees) at 50% power. Turns 90 degrees to the left.
Forward until Touch, then Back Up, then Turn Left Copy of the behavior pattern used earlier in the program Robot moves forward until it touches the wall, then backs up a little, and turns 90 degrees to the left.
Forward until Touch, then Back Up, then Turn Left Copy of the behavior pattern used earlier in the program Robot moves forward until it touches the wall, then backs up a little, and turns 90 degrees to the left.
Move Steering Block On Moves the robot forward at 50% power. No stopping condition. Start the motors on to move forward.
Wait Block Touch Sensor - Compare - State Stops the program from processing additional commands until the Touch Sensor value is '1' (Pressed) Robot waits until the Touch Sensor is pressed before continuing the program.
Move Steering Block Off Stops both motors of the robot. Stops the robot (after Wait Block finishes)