TRINITY ROBOTICS

Introduction 5: Bumper Switch

A bumper switch has a spring-loaded button which can recognize when it is pressed or released.

Add a bumper sensor to your robot and configure it in the devices window.  It is a “3-WIRE” sensor and must be plugged into ports A-H.

When you use sensors, it is best to put them in a WAIT UNTIL block rather than an IF-THEN-ELSE block.  IF-THEN blocks only check the condition one time and then move on.  To check the sensor more than once, you would have to put the blocks into a LOOP.  By using a WAIT UNTIL block, the program will stop there and keep checking the sensor until the condition becomes TRUE.  Then it moves on to whatever comes next in the program.

 

Task 1:

Attach the bumper switch to the back center of the robot.

 

Task 2:

Write a program that waits for you to press (and release) the switch then draws a green rectangle on the screen.

 

Task 3:

Wait for the bumper switch to be pressed (and released) then start driving slowly forward.  Wait for the bumper switch to be pressed (and released) again and stop driving.  

(Why is it important to always wait for the bumper to be released?)