Normally, We Use IR Obstacle Sensor to Initialize an Event, Like Lighting Up LED. That is commonly what we need for robotics. Like in our previous guide, Arduino IR Obstacle Sensor Buzzer With LED, we started LED and buzzer when an obstrucle was in front. But We Can Do the Opposite. That stop action makes a digital switch working like our regular switches – when you are present in front of a desk lamp, it will remain light up, but when you are absent, it will automatically shut down. We can reach that desired effect with other kind of sensors but using IR sensors made from components is more cheaper and sufficient for many applications. Here is Arduino IR Obstacle Detection Sensor For Dimming LED to Stop Event Facing an Obstacle.
That thing will help us for upgrading previous DIY guides for adding useful automation. Suppose, we are using one push button switch to start an event and another push button switch to stop the event. In modified form using IR Obstacle Detection Sensor, we can replace the second push button to stop the event. Like, you started a timer with push button to start buzzer after a time lapse which will not stop till you press the second push button. Using IR Obstacle Detection Sensor, you can stop that buzzer by simply going closer to it. PIR Motion Sensor does similar work but more specific around object which approached.
Arduino IR Obstacle Detection Sensor For Dimming LED : Circuit Diagram and Code
You will need quite basic components for this project :
---
- Regular IR Obstacle Detection Sensor (Not necessarily Sharp IR Sensor like shown in illustration)
- Arduino UNO or similar board
- Optionally a LED and one 220 Ohm resistor. Actually UNO’s LED will do the job of testing.
Here is illustration cum wiring :

In short :
1 2 3 4 5 6 7 |
# Sensor GND ===> Arduino's GND Vcc ===> Arduino's 5V Data ===> Arduino's 7th Pin # Optional LED LED ===> (+) to Arduino's 13th Pin LED ===> (-) to Arduino's GND |
Here is the code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
int LED = 13; // onboard LED int obstaclePin = 7; // Sensor input pin int hasObstacle = HIGH; // Note the logic, it is for else statement later void setup() { pinMode(LED, OUTPUT); pinMode(obstaclePin, INPUT); Serial.begin(9600); } void loop() { hasObstacle = digitalRead(obstaclePin); if (hasObstacle == HIGH) //Obsracle present { Serial.println("Something ahead"); digitalWrite(LED, LOW);//Dims the LED } else { Serial.println("Clear"); digitalWrite(LED, HIGH); //Illuminates the LED } delay(200); } |
Open the serial monitor of Arduino IDE and notice the debug output.
Tagged With obstacle detection arduino with led , arduino led buzzer obstacle sensor , arduino pir sensor buzzer dosent stop after object not present , led dimming by obstacle sensor arduinoHere’s what we’ve got for you which might like :
Additionally, performing a search on this website can help you. Also, we have YouTube Videos.
Take The Conversation Further ...
We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!
If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.
Contact Us