Automatic Street Light Project Using Arduino
Automatic Street Light Project Using Arduino
This project creates an energy-efficient street light system that automatically illuminates LED lights sequentially when a vehicle is detected by IR sensors. The lights turn on in the direction of vehicle movement and turn off after the vehicle passes.

How the System Works
- Two IR sensors are placed at opposite ends of the street light setup
- When a vehicle triggers the first sensor, LEDs light up sequentially from that side
- Each LED turns on with a 500ms delay, creating a smooth lighting effect
- As the vehicle passes the second sensor, LEDs turn off sequentially
- The same process works in reverse when a vehicle approaches from opposite direction
- System maintains lights for 2 seconds after vehicle detection for safety
Materials Required
- Arduino UNO - Buy Here
- IR Sensors (2x) - Buy Here
- Breadboard - Buy Here
- 220 Ohm Resistors (8x) - Buy Here
- Jumper Wires - Buy Here
- Rainbow Wires (2m) - Buy Here
- 8mm White LEDs (8x) - Buy Here
3D Files
Download the 3D printable files for the street light pole and enclosure:
Google DrivePrint these files using JLCPCB's 3D printing service:
Order NowStep-by-Step Assembly
1. Prepare the Components:
- Print all 3D parts for the street light structure
- Assemble the LED array with 220 ohm current-limiting resistors
- Mount the IR sensors at both ends of your setup
2. Wiring the Circuit:
- Connect the first IR sensor to pin 3 of Arduino
- Connect the second IR sensor to pin 2 of Arduino
- Connect LEDs to pins 4 through 11 (with resistors)
- Use breadboard for power distribution (5V and GND connections)
3. Arduino Code:
- Upload the provided Arduino code
- Adjust the 500ms delay if different lighting speed is desired
- Modify the 2-second delay after vehicle passage as needed
4. Testing the System:
- Move an object past the first sensor - LEDs should light sequentially
- Pass the object through second sensor - LEDs should turn off sequentially
- Test from both directions to verify bidirectional operation
🎥 Circuit Diagram is Shown in Video.
Arduino Code
Upload this code to your Arduino UNO after completing the circuit connections:
int IRSensor1 = 3; int IRSensor2 = 2; void setup() { pinMode(IRSensor1, INPUT); pinMode(IRSensor2, INPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT); } void loop() { int statusSensor1 = digitalRead(IRSensor1); int statusSensor2 = digitalRead(IRSensor2); // If IRSensor1 is triggered, turn on LEDs sequentially from pin 4 to pin 11 if (statusSensor1 == 0) { // Turn on LEDs sequentially digitalWrite(4, HIGH); delay(500); digitalWrite(5, HIGH); delay(500); digitalWrite(6, HIGH); delay(500); digitalWrite(7, HIGH); delay(500); digitalWrite(8, HIGH); delay(500); digitalWrite(9, HIGH); delay(500); digitalWrite(10, HIGH); delay(500); digitalWrite(11, HIGH); delay(500); // Wait until IRSensor2 is triggered while (digitalRead(IRSensor2) == 1) { // Do nothing, just wait } // Wait until IRSensor2 is no longer triggered (passed through it) while (digitalRead(IRSensor2) == 0) { // Do nothing, just wait } delay(2000); // Turn off LEDs sequentially from pin 11 to pin 4 digitalWrite(4, LOW); delay(500); digitalWrite(5, LOW); delay(500); digitalWrite(6, LOW); delay(500); digitalWrite(7, LOW); delay(500); digitalWrite(8, LOW); delay(500); digitalWrite(9, LOW); delay(500); digitalWrite(10, LOW); delay(500); digitalWrite(11, LOW); delay(500); } // If IRSensor2 is triggered, turn on LEDs sequentially from pin 11 to pin 4 if (statusSensor2 == 0) { // Turn on LEDs sequentially digitalWrite(11, HIGH); delay(500); digitalWrite(10, HIGH); delay(500); digitalWrite(9, HIGH); delay(500); digitalWrite(8, HIGH); delay(500); digitalWrite(7, HIGH); delay(500); digitalWrite(6, HIGH); delay(500); digitalWrite(5, HIGH); delay(500); digitalWrite(4, HIGH); delay(500); // Wait until IRSensor1 is triggered while (digitalRead(IRSensor1) == 1) { // Do nothing, just wait } // Wait until IRSensor1 is no longer triggered (passed through it) while (digitalRead(IRSensor1) == 0) { // Do nothing, just wait } delay(2000); // Turn off LEDs sequentially from pin 4 to pin 11 digitalWrite(11, LOW); delay(500); digitalWrite(10, LOW); delay(500); digitalWrite(9, LOW); delay(500); digitalWrite(8, LOW); delay(500); digitalWrite(7, LOW); delay(500); digitalWrite(6, LOW); delay(500); digitalWrite(5, LOW); delay(500); digitalWrite(4, LOW); delay(500); } }
Code Explanation:
Setup:
Configures two IR sensors as inputs (pins 2-3) and eight LED pins as outputs (pins 4-11).
Loop:
Continuously checks both IR sensors. When triggered, it sequentially lights LEDs in the direction of movement (500ms delay between each) and turns them off after vehicle passage (with 2-second lighting buffer). Works bidirectionally.
Why Choose This Design?
- ✅ Energy Efficient: Lights only activate when vehicles are present
- 🚗 Direction-Sensitive: Smart sequential lighting based on vehicle direction
- 💡 Smooth Operation: 500ms delay creates pleasant lighting effect
- 🛠️ Easy to Scale: Can be expanded for longer streets with more LEDs
- 💰 Cost Effective: Uses affordable, widely available components
- 🌱 Eco-Friendly: Reduces light pollution and energy waste
Dear Friend, After watching your videos, I guess that you are a very creative and innovative engineer. Myself, Dr. George Peter, Director of Renewable Energy Centre, Mithradham, the first fully solar educational instituion in India dedicated to the promotion of environment and renewable energy established in Cochin, Kerala. (www.mithradham.org ). I am a post doctral fellow of Max-Plack Institute, Germany and have very log time contact with Germany. I retired from my teaching profession in the S.H. College, Thevara, Kochi (www.shcollege.ac.in) in 2006 and was employed partime in Rajagiri Engineering College, Kochi (www.rajagiritech.ac.in) as guest professor for engineering Physics. I continue as the founder and director of Renewable Energy Centre, MIthradham. I think your talents could be very well utilised for various groups coming to Mithradham, especially for College students. If you are interested to associate with Mithradham in any manner , pls. call/whatsapp me +91 9847747650 . Thank you.
ReplyDelete