Use of HC-SR04 sensor and I2C LCD display by Micro:bit board

Опубликовано: 20 Март 2026
на канале: Robotique Site
338
4

For more details you can read this tutorial :
https://www.robotique.site/tutorial/u...

The purpose of this project is to measure the distance between the HC-SR04 ultrasonic sensor and a detected object and display it on the I2C LCD screen.
Here are some common goals for this project:
Navigation and Obstacle Avoidance:
This project is commonly used in navigation systems for vehicles, drones, and robots to measure distances and avoid obstacles. It helps in providing a safe path by detecting and navigating around obstacles.
Industrial Automation:
In industrial settings, this project can be used for automating processes by precisely measuring distances between objects or components on a production line. This ensures accurate positioning and alignment.
Proximity Detection:
This project is employed for detecting the proximity of objects or individuals. This is useful in security systems, access control, and automation where actions need to be triggered based on the presence or absence of objects within a certain range.
Parking Assistance:
This project is utilized in parking assistance systems in vehicles. It helps drivers by measuring the distance between the vehicle and obstacles, providing visual or audible alerts to avoid collisions during parking maneuvers.
Surveillance and Security:
This project is used in security systems to monitor areas and detect any unauthorized intrusion. By measuring distances, security systems can trigger alarms when someone enters a restricted zone.
Medical Applications:
In medical devices, this project can be used for various purposes, such as measuring the distance between ultrasound transducers and the body surface, monitoring fluid levels in medical bags, or assisting visually impaired individuals in navigation.
Level Monitoring:
This project is employed in level monitoring systems to measure the distance between a sensor and the surface of a liquid or solid material. This is commonly used in tanks for monitoring fluid levels.
Traffic Control:
This project can contribute to traffic management by measuring distances between vehicles on the road. This information can be used to implement intelligent traffic control systems.
IoT Applications:
In the Internet of Things (IoT) context, this project can be integrated into various devices and applications for smart homes, smart cities, and industrial IoT to enable distance-based automation and monitoring.
Education and Research:
This project serves as a valuable tool in educational projects and scientific research. It allows students and researchers to experiment with and understand principles related to distance measurement, sensors, and electronics.

In summary, the purpose of our project is to provide accurate and reliable distance information for a wide range of applications, including navigation, automation, security, healthcare, and more. The specific goals and benefits depend on the requirements of the particular use case or industry.

The components required to use HC-SR04 sensor and I2C LCD display by Micro:bit
Micro:bit board:
The GPIO expansion card for the Micro:bit card
HC-SR04 ultrasonic Sensor
I2C LCD Display (usually 16x2)
Jumper Wires:
Breadboard:

Attaching the I2C LCD Display :
Connect the SDA (data line) of the LCD I2C 1602 display to P20 pin  of the Micro:bit board.
Connect the SCL (clock line) of the LCD I2C 1602 display to P19 of the Micro:bit board.
Connect the VCC pin of the LCD I2C 1602 display to the 5V pin of the GPIO board or another energy source .
Connect the GND pin of the LCD I2C 1602 display to GND pin of the Micro:bi board.

Attaching the HC-SR04 sensor :
Connect the VCC(+) pin of the HC-SR04 ultrasonic sensor to the 3.3V pin on the Micro:bit board.
Connect the Trig pin of the HC-SR04 ultrasonic sensor to P0 pin on the Micro:bit board.
Connect the Echo pin of the HC-SR04 ultrasonic sensor to P1 pin on the Micro:bit board.
Connect the GND(-) pin of the HC-SR04 sensor to any ground (GND) pin on the Micro:bit board.

To program Micro:bit to calculate and display the distance between the HC-SR04 sensor and an object I2C LCD display, you can follow the steps below.
1- Open the MakeCode editor at https://makecode.microbit.org/.
2- Create a new project by clicking on "New Project."
3- Add the HC-SR04 extension:

4- In the search box, type "sonar" to find the bluetooth extension.
5- In the MakeCode editor, look for the "Extensions" option and click on it.
6- In the search bar, type "I2C LCD," and you should find an extension for the I2C LCD display. Add it to your project.
7- Now, you can start programming the Micro:bit to use the HC-SR04 sensor and LCD I2C screen.