Ever wanted to build a simple alert system that detects nearby objects? In this guide, you’ll learn how to create a basic Arduino-based obstacle detection system using an IR sensor and a buzzer. This is a great beginner project to get started with Arduino, sensors, and digital outputs—and you’ll complete it in just a few steps!
![]() |
Simple obstacle detector using an IR sensor |
Components Required
To get started, you will need the following components:
![]() |
Components required for this tutorial |
✅ Arduino UNO board
✅ IR Obstacle Sensor
✅ Jumper Wires
✅ USB cable for Arduino
✅ Buzzer
๐ ️ Circuit Wiring
Here’s how to connect each component to the Arduino:
![]() |
IR sensor wiring |
IR Sensor
✅ VCC → 5V on Arduino
✅ GND → GND on Arduino
✅ OUT → Digital pin 2 on Arduino
![]() |
Buzzer sensor wiring |
Buzzer
![]() |
Wiring diagram |
๐ป Uploading the Code
After wiring everything up, connect the Arduino to your computer using a USB cable. Then, upload the following code, or you can download the code HERE.
const int irSensorPin = 2; const int buzzerPin = 8; void setup() { pinMode(irSensorPin, INPUT); pinMode(buzzerPin, OUTPUT); Serial.begin(9600); } void loop() { int sensorValue = digitalRead(irSensorPin); if (sensorValue == LOW) { digitalWrite(buzzerPin, HIGH); Serial.println("Obstacle detected!"); } else { digitalWrite(buzzerPin, LOW); } delay(100); }
![]() |
Open Arduino IDE and copy-paste the code |
๐งช Final Test
Once the code is uploaded, place your hand or an object in front of the IR sensor. The buzzer will beep, indicating that the sensor has detected an object. When the object is removed, the buzzer stops.
![]() |
The IR sensor and buzzer turn ON and beep when an object is detected. |
๐ Conclusion
And that’s it! This Arduino project is simple, effective, and a great hands-on introduction to IR sensors and digital outputs. Whether you’re a student or a hobbyist, this is a great first step into the world of embedded electronics!
๐ฆ Where to Buy
Shopee:
Lazada:
Aliexpress:
๐ฅ Watch the Full Video Tutorial
๐ If you found this guide helpful, share it with fellow makers! For more tutorials, subscribe to our YouTube channel and follow us on social media. ๐
#arduino #irsensor #diyproject #obstacledetector #buzzersensor #arduinoproject #electronics
No comments:
Post a Comment