8. Touch Sensor

You must first complete 7. Custom Images and Sounds before viewing this Lesson

8.1. What is a sensor?

A sensor lets an EV3 program measure and collect data about is surroundings

The EV3 sensors include:
• Color – measures color and darkness
• Gyro – measures rotation of robot
• Ultrasonic – measures distance to nearby surfaces
• Touch – measures contact with surface
• Infrared – measures IR remote’s signals

8.2. What is a Touch Sensor?

• Touch Sensor can detect when the sensor’s red button has been pressed or released
• With this information, you can program an action when the sensor is:
o Currently Pressed
o Currently Released
o Pressed and Released Just Before (Bumped)
• When might you use this sensor?
o Useful for programming “moving until touch sensor is pressed/released/bumped”
o For example, if you put a touch sensor on the front the robot, you can have it stop moving if it runs into something.
o You can also have your program start or stop when a touch sensor is pressed.

8.3. What does “Bumped” Mean?

The sensor basically is like a True/False switch

“Bumped” can be tricky. What conditions must be there for the sensor to read True for Bumped?

8.4. How Do you program with the Touch Sensor?

There is a Touch Sensor Block in the Yellow Tab, but there is a Wait for Touch in the Orange Tab. What is the difference?

Yellow Sensor Tab: Sensor Blocks
Used to Read and Compare Sensor Values

Orange Flow Tab: Wait for Block
Used to wait for a sensor reading (or time)

8.5. Move ON and OFF

What would happen if you placed a Move Steering Block and left the motor “On”?
Would the robot…
1) Move?
2) Move for a little while?
3) Not move at all?
ANS. Not move at all.

What does Motor Off do?
Tip: Motor On needs to be followed by another block (e.g. Wait Block)

Challenge 1

Program your robot to move straight until you tap the sensor with your hand.

Hint: You will combine: Move Steering + Wait Block

Challenge 2

Program your robot to move until it hits the edge of a wall. Then back up and turn right 90 degrees.

Hint: You will combine Move Steering + Turning + Wait Block


Why did you use MOTOR ON for these challenges?
You want to read the sensor while the motor is on.

Why do we use the WAIT FOR BLOCK in these challenges?
We need to program to wait for the correct reading

What is the difference between PRESSED, RELEASED and BUMPED?
PRESSED = pushed in, RELEASED = not pushed,
BUMPED = pressed and released recently

What are some situations you might want to use each of these for?
PRESSED = running into a wall, BUMPED = tapped by hand
RELEASED = no longer touching a wall

Back to: Module 3. Programming