Touch/Bump (Bumper) Sensor
React correctly when you bump
The robot vacuum will bump into obstacles as it moves around the room. Look at which bumper is pressed (0 or 1) and choose what the robot does: back up, turn right or turn left. Sometimes both bumpers are pressed at once; then the order of the code decides.
Bumper sensors are a simple mechanical switch: when they touch an object, the circuit closes. The bumper on a robot vacuum, elevator door sensors and the button-collision systems in toy robots all work this way. Simple but safe!
The front bumper of a Roomba robot vacuum is a bumper sensor. It changes direction when it hits furniture.
If the obstacle is on the left, turn right; if it’s on the right, turn left; if it’s straight ahead, back up. The code checks the front bumper first, so backing up is right when both bumpers are pressed.