An ultrasonic sensor detects the distance between the sensor and the closest object in front of it. It uses ultrasound which is a sound with a frequency higher than what humans can hear. As you probably already know, sound can bounce and reflect from surfaces to create an echo. This echo is what the sensor uses to estimate the distance. The sensor sends out a burst of ultrasound and then waits for the echo. By knowing the speed of sound and the time between the burst and its detection, it can calculate the distance – the longer the detection time, the farther away the object while the shorter the time, the closer the object.
Materials
- 1 Arduino Uno board
- 1 Basic education shield
- 1 Ultrasonic sensor
- 4 jumper wires
Instructions
- Connect VCC to 5V, Trig to digital pin 11, Echo to digital pin 12 and GND to GND as in the illustration.
Open File>Example>BasicEducationShield>Help>UltrasonicSensor.
Upload the code and open the serial monitor. Put your hand in front of the sensor, the numbers shown in the serial monitor represent the distance between your hand and the sensor in centimeters.