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.
The obstacle detection system using HC-SR04, I2C LCD screen, LED, buzzer, and Arduino UNO operates based on the principles of ultrasonic distance measurement and sensor integration. Here's a step-by-step explanation of how the system works:
1- Ultrasonic Distance Measurement (HC-SR04):
The HC-SR04 ultrasonic sensor emits ultrasonic waves using the transducer on the trigger pin.
The waves travel through the air and bounce off any obstacle in their path.
The transducer on the echo pin receives the reflected waves.
2- Calculation of Distance:
The Arduino measures the time it takes for the ultrasonic waves to travel to the obstacle and back.
Using the speed of sound in air (approximately 343 meters per second), the Arduino calculates the distance to the obstacle.
3- Obstacle Detection:
A conditional statement checks if the measured distance is less than a predefined threshold (e.g., 20 cm).
If the distance is less than the threshold, an obstacle is considered detected.
4- Display on I2C LCD Screen:
The I2C LCD screen serves as a user interface by displaying relevant information obstacle detection status.
5- LED Indication:
An LED is used to provide a visual indication of obstacle detection.
The LED is turned on when an obstacle is detected and turned off otherwise.
6- Buzzer Alert:
A buzzer is employed to provide an audible alert when an obstacle is detected.
The buzzer is activated, producing a tone, when the system identifies an obstacle.
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
The HC-SR04 is an ultrasonic distance measuring sensor module.
I2C LCD Display (usually 16x2)
This screen is used for displaying a alert message if the HC-SR04 sensor detects an obstacle.
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)
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:
For making temporary connections and wiring between components.
Breadboard:
A breadboard is a useful tool for creating temporary electronic circuits. It allows you to connect components without soldering.
Attaching the I2C LCD Display :
- connect the VCC pin of the display to 5V pin of the Arduino UNO
- connect the GND pin of the display to GND pin of the Arduino UNO
- connect the SDA pin of the display to A4 pin of the Arduino UNO
- connect the SCL pin of the display to A5 pin of the Arduino UNO
Attaching the HC-SR04 sensor :
- 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 pin 2 on the Arduino UNO board.
- Connect the Echo pin of the HC-SR04 ultrasonic sensor to pin 3 on the Arduino UNO board.
- Connect the GND(-) pin of the DHT22 sensor to any ground (GND) pin on the Arduino UNO board.
Attaching the buzzer :
- Connect the (+) terminal of buzzer to pin 4 on the Arduino UNO board.
- Connect the (-) terminal of buzzer to GND pin on the Arduino UNO board.
Attaching the red LED :
- Connect the negative terminal (cathode) of each LED to the ground (GND) of the Arduino UNO board.
- Connect a resistor between the pin 5 and the positive terminal (anode) of the LED
To program an obstacle detection system controlled by Arduino, you'll need to follow these steps.
1- import this library :Ultrasonic for HC-SR04 sensor
2- import this library : LiquidCrystal_I2C for I2C LCD screen
3- Create a new Arduino script and write the following code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
#include "Ultrasonic.h" #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 20, 4); Ultrasonic ultrasonic(2, 3); // Trig et Echo int buzzer_pin = 4; int redled_pin = 5; void setup() { Serial.begin(9600); lcd.init(); // initialization of the display lcd.backlight(); // activates the backlight pinMode(buzzer_pin, OUTPUT); pinMode(redled_pin, OUTPUT); } void loop () { int distance = ultrasonic.Ranging(CM); Serial.print("distance= "); Serial.print(distance); Serial.println(" cm"); // If the HC-SR04 sensor detects an obstacle if (distance < 4) { // ring the buzzer digitalWrite(buzzer_pin, HIGH); // turn on red LED digitalWrite(redled_pin, HIGH); lcd.setCursor(0, 0); lcd.print("attention !!!"); lcd.setCursor(0, 1); lcd.print("obstacle detected"); } else { lcd.clear(); // stop the buzzer digitalWrite(buzzer_pin, LOW); // turn off red LED digitalWrite(redled_pin, LOW); } delay(100); } |
This code continuously monitors the distance using the HC-SR04 sensor, displays the distance on the I2C LCD screen, and triggers the LED and buzzer if an obstacle is detected within a threshold distance (4 cm in this example).
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.
Zaouiet Kontech-Jemmel-Monastir-Tunisia
+216 92 886 231
medaliprof@gmail.com
Robotic site created by MedAli-Teacher info