Activity 5 - Ultrasonic
Activity 5 - Ultrasonic
ULTRASONIC SENSOR
INTRODUCTION
The sensor emits an ultrasound at 40 000 Hz which travels through the air
and if there is an object or obstacle on its path It will bounce back to the
module. Considering the travel time and the speed of the sound you can
calculate the distance.
In order to generate the ultrasound, you need to set the Trig on a High State
for 10 µs. That will send out an 8-cycle sonic burst which will travel at the
speed sound and it will be received in the Echo pin. The Echo pin will output
the time in microseconds the sound wave traveled.
The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo.
The Ground and the VCC pins of the module needs to be connected to the Ground
and the 5 volts pins on the Arduino Board respectively and the trig and echo pins
to any Digital I/O pin on the Arduino Board.
OBJECTIVE
During this activity, you will help students to achieve following objectives:
• Understanding principle and operations of HCSR04 Sensor.
• Design algorithm and flowchart to detect using HCSR04 sensor.
• Programming HCSR04 sensor using Arduino API for Arduino/Genuino UNO.
• Interfacing HCSR04 sensor with Arduino/Genuino UNO using digital pins.
APPLICATION
• Robotics Barrier, Object distance measurement., Level detection, Public security, Parking detection
. ALGORITHM FLOWCHART
Step 1 Start
Step 8 End
PROGRAMMING:
HARDWARE INSTRUCTIONS:
Connect GND pin of HCSR04 to GND on the Arduino Arduino HCSR04 sensor pin
UNO Board. UNO Pin
Connect trig pin of HCSR04 to d11 and echo pin to 5V VCC
d12 on the Arduino UNO Board
GND GND
Connect VCC pin of HCSR04 to 5V on the Arduino
UNO Board.
D11 Trig
Connect power supply to the Arduino board through
USB from your laptop or desktop. D12 Echo
Open Arduino IDE under Tools → Board select
Arduino Genuino UNO
Under Tools → Serial Port select the Com # where
the Arduino Genuino UNO is connected to
Write the above code on Arduino IDE
Upload to the Arduino UNO Board by clicking the
upload button
Monitor the value of the HCSR04 in the Serial
Monitor.