Sensors

Sensors in EV3 are very important because they help the robot "see" and "feel" its surroundings in order for EV3 to make smart decisions based on what it senses.

There are 5 type of sensors:

Untrasonic Sensor

ultrasonic

-> The Ultrasonic Sensor in EV3 is a special device that helps the robot "see" using sound waves.

->It's kind of like how bats or dolphins or submarines use echolocation to find their way around!

1- The Ultrasonic Sensor sends out sound waves, which are like tiny vibrations you can't hear. These sound waves bounce off objects and come back to the sensor.

echo

2- By timing how long it takes for the sound waves to return, the sensor can figure out how far away the object is.

A way to know the distance (cm):

ev3-connected-ultrasonic

It is show in centimeter(cm)

It shows the centimers that it's away from an object

Try putting your hand near and far the sensor to try it out!

Wait Until "distance less than 15cm"

15cm

Notice that it's approximate to 15cm. Not exactly 15cm.

1-untrasonic

1- Press

2- Robot begin moving

1-ultrasonic-wait-Until

1- Wait [robot don't do anything] Until [Touch sensor is "pressed"]

2- Robot moves BACKWARD for 500 degrees at the speed of 20%.


Repeat until "distance less than 10cm"

10cm

Notice that it's approximate to 10cm. Not exactly 10cm.

Ultrasonic 10cm

Notice that it does the opposite from the last one

1- Robot "start moving"

2- stop when sensor is "pressed"

2-ultrasonic-Repeat-Until

1- Wait [wheels move backward at speed of 20% repeatedly] Until [touch sensor is "pressed"]

2- Stop moving.


Key-Takeaways: Why is Ultrasonic sensor important for programming?

Time for a quiz!

Question goes here

Challenge for you

Ultrasonic-you

Hint:

-> You use 2 times the ultrasonic sensor

1- Make a spin turn

2- stop moving

-> The distance is less than 10cm

-> The speed it's up to you. BUT it has to be slow for the ultrasonic to detect the object.

3-ultrasonic-you

Notice I added 2 type of "wait until". You can use either or both.

1- Wait [robot "start moving" backward at speed 40%] Until[ultrasonic sensor sense 10cm away from obstacle] Then [Spin turn 320 degrees and "start moving" backward at the speed of 20%].

2- Wait [robot "start moving" backward at speed of 20%] Until [ultrasonic sensor sense 10cm away from obstacle and Stop moving]