Obstacle detection system using HC-SR04 sensor and Micro:bit

Micro:bit 28-02-24
270 0

Introduction

1- Principle of obstacle detection system using HC-SR04 and Micro:bit

2- Necessary system components

3- Obstacle detection system wiring diagram

4- Program the Micro:bit card to control the obstacle detection system

 

 

Introduction

An obstacle detection system is a technology designed to identify and alert users or autonomous systems about obstacles or hazards in their environment. These systems are commonly used in various applications, including robotics, autonomous vehicles, drones, industrial automation, and assistive technologies. The primary goal is to enhance safety and prevent collisions by providing real-time information about the presence of obstacles.

Here are some key components and technologies often employed in obstacle detection systems:

Sensors:

Ultrasonic Sensors: These sensors use ultrasonic waves to measure the distance between the sensor and an object. They are commonly used for short-range obstacle detection.

Infrared Sensors: Infrared sensors can detect obstacles by emitting and receiving infrared radiation. They are suitable for both short and medium-range applications.

Lidar (Light Detection and Ranging): Lidar systems use laser beams to measure distances and create a detailed 3D map of the surroundings. Lidar is often used in autonomous vehicles and robotics for accurate obstacle detection.

Radar (Radio Detection and Ranging): Radar systems use radio waves to detect the presence and location of objects. They are effective for long-range obstacle detection and are commonly used in automotive applications.

Computer Vision:

Cameras: Image sensors and cameras can be used to capture visual information, and computer vision algorithms can analyze the images to identify obstacles. This method is widely used in various applications, including surveillance systems and autonomous vehicles.

Depth Sensors: Depth-sensing cameras or sensors, such as time-of-flight (ToF) cameras, provide information about the distance to objects, aiding in obstacle detection.

Data Processing and Fusion:

The raw data from sensors need to be processed and fused to create a comprehensive understanding of the environment. This involves filtering, combining, and interpreting data to accurately identify obstacles.

Algorithms:

Various algorithms, including machine learning and artificial intelligence techniques, can be employed to improve the accuracy and reliability of obstacle detection. These algorithms can adapt to different environments and learn from experience.

Alert Systems:

Once an obstacle is detected, the system needs to communicate this information to the user or the controlling system. This could be through visual alerts, audible alarms, or other communication methods.

Integration with Control Systems:

In many applications, obstacle detection systems are integrated with control systems to enable automated responses, such as slowing down a vehicle or stopping a robot when an obstacle is detected.

Principle of obstacle detection system using HC-SR04 and Micro:bit

The obstacle detection system based on HC-SR04, LED, buzzer, and Micro:bit card operates on the principle of using ultrasonic distance measurement to detect obstacles and then providing visual and audible feedback through the LED and buzzer. Here's a step-by-step explanation of the system's principle:

1- Ultrasonic Emission: The HC-SR04 ultrasonic sensor emits a short burst of ultrasonic waves when triggered by Micro:bit board. This is done by sending a pulse to the trigger (Trig) pin.

2- Wave Reflection: The ultrasonic waves travel through the air until they encounter an obstacle. Upon hitting the obstacle, the waves are reflected back towards the sensor.

3- Echo Reception: The HC-SR04 sensor detects the echoed waves on its echo (Echo) pin.

4- Distance Calculation: The Micro:bit board measures the time interval between sending the trigger signal and receiving the echo. Using the speed of sound in the air (approximately 343 meters per second at 20 degrees Celsius), it calculates the distance to the obstacle.

5- Obstacle Detection: The Micro:bit board then compares the calculated distance with a predefined threshold. If the distance is below a certain threshold, it is determined that an obstacle is present.

6- LED and Buzzer Activation: If an obstacle is detected, the Micro:bit board activates the LED and his buzzer. The LED provides a visual indicator, and the buzzer produces an audible warning.

7- Feedback Control: The system continuously monitors the distance, and if the obstacle moves or is no longer present, the LED and buzzer are deactivated.

Necessary system components

Micro:bit board:

Micro:bit board

The Micro:bit board is a small, programmable microcontroller board designed for education and beginner-friendly coding projects. It was developed by the BBC, in collaboration with various partners, as a tool to introduce young people to programming and electronics.

The GPIO expansion card for the Micro:bit card

The GPIO expansion card for the Micro:bit card

The GPIO expansion board for the Micro:bit board expands the capabilities of the Micro:bit board by adding more input/output (GPIO) pins and additional functionality.

HC-SR04 ultrasonic Sensor

HC-SR04

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

LED 

LED

In an obstacle detection system, an LED (Light Emitting Diode) can be used as a visual indicator to provide feedback about the detection status. The LED can be programmed to turn on or off based on whether an obstacle is detected within a certain range.

Resistance (220 ohm)

Résistance

The resistance needed for an LED (Light Emitting Diode) in a circuit is determined by Ohm's Law, which states that the resistance (R) is equal to the voltage (V) divided by the current (I).

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.

Obstacle detection system wiring diagram

Obstacle detection system wiring diagramObstacle detection system wiring diagram

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.

Attaching the red LED :

- Connect the negative terminal (cathode) of each LED to the ground (GND) of the Micro:bit board.

- Connect a resistor between the pin P2 and the positive terminal (anode) of the LED

Program the Micro:bit card to control the obstacle detection system

To program an obstacle detection system using HC-SR04, an LED, and the Micro:bit , you'll need to follow these steps:

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:

Look for "Extensions" and click on it.

In the search box, type "sonar" to find the bluetooth extension.

4- Now, you can start programming the Micro:bit using this Makecode program :

maxbutton id="1" url="https://www.robotique.site/wp-content/uploads/2024/02/microbit-obstacle.hex" text="Download program" ]

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