Automatic Street Light Controller using Arduino
Introduction:
Needs no manual operation for switching ON and OFF. When there is a need of light it automatically switches ON. When darkness rises to a certain level then sensor circuit gets activated and switches ON and when there is other source of light i.e. daytime, the street light gets OFF.
Components Used:
- Arduino UNO
- LDR (Light Dependent Resistor)
- LED (Light Emitting Diode)
- Resistor
- Breadboard
- Connecting Wires
Software:
- Arduino IDE
Connections:
- Arduino 3rd pin connected to LED +ve
- Arduino GND connected to LED -ve through 4.7k
- Arduino +5v is connected to LDR One End.
- Arduino A0 pin is connected to LDR other end
- Arduino GND is connected to LDR other end with 4.7k
Circuit Diagram:
Software Installation:
Arduino IDE:
- Install and Launch Arduino IDE 1.8.15
- Link-> https://www.arduino.cc/en/software
- Go to Tools->Board->Boards Manager
- Select Arduino UNO Board.
- Select suitable Port number.
Code:
#include<SoftwareSerial.h>
int sensorPin=A0;
int sensorValue = 0;
int led = 3;
void setup()
{
pinMode(led, OUTPUT);
Serial.begin(9600);
// put your setup code here, to run once
}
void loop()
{
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);
if(sensorValue < 100)
{
Serial.println(“LED light on”);
digitalWrite(led,HIGH);
delay(1000);
}
digitalWrite(led,LOW);
delay(sensorValue);
// put your main code here, to run repeatedly
}
Working:
- When there is low amount of light the light automatically glows and when there is sufficient amount of light it automatically turns off the light.
- Here based on our room condition the threshold value we took is 100 for the LDR sensor.
- When we place a hand on LDR(Not allowing any light on LDR) arduino automatically turns on the LED.
- When we remove our hand on LDR. Arduino automatically Turns Off LED.