Week 13 – Ultrasonic sensor

Arduino
Introduction – Ultrasonic Sensor


The HC-SR04 ultrasonic sensor uses sonar to determine the distance to an object like bats or dolphins do.

It offers excellent non-contact range detection with high accuracy and stable readings in an easy-to-use package. From 2cm to 400 cm or 1” to 13 feet. It operation is not affected by sunlight or black material like Sharp rangefinders are (although acoustically soft materials like cloth can be difficult to detect). It comes complete with ultrasonic transmitter and receiver module.
It essentially gives your Arduino eyes and can prevent your robot from crashing or falling off a table. It has also been used in turret applications, water level sensing, and even as a parking sensor. This simple project will use the HC-SR04 sensor with an Arduino and a Processing sketch to provide a neat little interactive display on your computer screen.

Pins
⦁ VCC: +5VDC
⦁ Trig : Trigger (INPUT)
⦁ Echo: Echo (OUTPUT)
⦁ GND: GND

Parts List
⦁ Arduino UNO R3
⦁ One (1) HC-SR04 Ultrasonic Sensor
⦁ One (1) Red LED
⦁ One (1) Green LED
⦁ Two (2) 330 ohm Resistors

Circuit Diagram:

Build the circuit and program to measure distance.
Experiment:

Turn the Red LED ON when distance is less than 20 cm and Green LED ON when distance is greater than 20 cm.

Homework:
Buzzer Programming:

Piezo buzzer can be used to make sound for different frequencies.
Ultrasonic sensor activity with buzzer:
⦁ (1x) Arduino Uno
⦁ (1x) Breadboard
⦁ (1x) HC-SRO4 Ultrasonic Sensor
⦁ (1x) Buzzer
⦁ (1x) 100 ohm Resistors
 In this activity you will make the ultrasonic sensor trigger the buzzer to buzz when it senses an object at a certain distance.
Choose any frequency for 200 Hz to 400 Hz to complete the task.
Note: Use DFROBOT Buzzer block in ArduBlock to program the buzzer.