Control the HC-SR04 ultrasonic sensor using the Arduino UNO

Arduino UNO 13-02-24
176 0

Tutorial plan

1- What is the HC-SR04 ultrasonic sensor ?

2- The components required to use HC-SR04 ultrasonic sensor by Arduino UNO board

3- Mounting the Arduino UNO board with the HC-SR04 ultrasonic sensor

4- Program the Arduino UNO board to determine the distance between the HC-SR04 sensor and an object

 

 

What is the HC-SR04 ultrasonic sensor ?

The HC-SR04 is an ultrasonic distance measuring sensor module. It is commonly used for measuring distances and detecting obstacles in various applications, such as robotics, home automation, and industrial projects. The sensor works on the principle of ultrasonic sound waves.

Here's a basic overview of how the HC-SR04 sensor works:

Ultrasonic Transmitter: The sensor has an ultrasonic transmitter that emits short pulses of ultrasonic sound waves.

Ultrasonic Receiver: It also has a receiver that listens for the echo of the transmitted ultrasonic waves.

Distance Calculation: The sensor calculates the time taken for the ultrasonic waves to travel to the target object and back. Using the speed of sound in the air, it then calculates the distance to the object.

Output: The sensor provides an output in the form of a pulse width or a voltage signal that corresponds to the measured distance.

The HC-SR04 typically has four pins:

VCC (Power): Connects to the positive power supply (5V or 3.3V).

Trig (Trigger): Sends a short pulse to trigger the sensor to transmit ultrasonic waves.

Echo: Receives the echo signal and outputs a pulse whose width corresponds to the distance.

GND (Ground): Connects to the ground of the circuit.

Arduino UNO and other microcontrollers are often used to interface with the HC-SR04 sensor, making it a popular choice for hobbyists and developers working on projects involving distance measurement or obstacle avoidance. The sensor's simplicity, low cost, and ease of use contribute to its widespread popularity in the maker community.

The components required to use HC-SR04 ultrasonic sensor by Arduino UNO board

Arduino UNO :

Arduino Uno

The Arduino Uno is an open-source microcontroller board that is part of the Arduino platform. It is designed for ease of use and is widely used in the maker and hobbyist communities for prototyping and creating various electronic projects.

HC-SR04 ultrasonic Sensor

HC-SR04

The HC-SR04 is an ultrasonic distance measuring sensor module.

Jumper Wires:

Jumper wires

For making temporary connections and wiring between components.

Breadboard:

Test plate

A breadboard is a useful tool for creating temporary electronic circuits. It allows you to connect components without soldering.

Mounting the Arduino UNO board with the HC-SR04 ultrasonic sensor

Mounting the Arduino UNO board with the HC-SR04 ultrasonic sensorMounting the Arduino UNO board with the HC-SR04 ultrasonic sensor

This represents the connections between the HC-SR04 ultrasonic sensor and the Arduino UNO board:

- Connect the VCC(+) pin of the HC-SR04 ultrasonic sensor to the 3.3V pin on the Arduino UNO board.

- Connect the Trig pin of the HC-SR04 ultrasonic sensor to GPIO16 pin on the Arduino UNO board.

- Connect the Echo pin of the HC-SR04 ultrasonic sensor to GPIO17 pin on the Arduino UNO board.

- Connect the GND(-) pin of the HC-SR04 sensor to any ground (GND) pin on the Arduino UNO board.

Program the Arduino UNO board to determine the distance between the HC-SR04 sensor and an object

To measure the distance using an HC-SR04 sensor with an Arduino UNO board using MicroPython, you need to import this library Ultrasonic for HC-SR04 sensor and then write this program to interface with the sensor :

This program continuously measures the distance between the HC-SR04 and the object sensor and prints the result.

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

+216 92 886 231

medaliprof@gmail.com

Pictures of the articles

Robotic site created by MedAli-Teacher info