Recent Posts

Automatic Street Light

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:

  1. Arduino UNO
  2. LDR (Light Dependent Resistor)
  3. LED (Light Emitting Diode)
  4. Resistor
  5. Breadboard
  6. Connecting Wires

Software:

  1. Arduino IDE

Connections:

  1. Arduino 3rd pin connected to LED +ve
  2. Arduino GND connected to LED -ve through 4.7k
  3. Arduino +5v is connected to LDR One End.
  4. Arduino A0 pin is connected to LDR other end
  5. Arduino GND is connected to LDR other end with 4.7k

Circuit Diagram:




Software Installation:


Arduino IDE:

  1. Install and Launch Arduino IDE 1.8.15
  2. Link-> https://www.arduino.cc/en/software
  3. Go to Tools->Board->Boards Manager 
  4. Select Arduino UNO Board.
  5. 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:

  1. 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.
  2. Here based on our room condition the threshold value we took is 100 for the LDR sensor. 
  3. When we place a hand on LDR(Not allowing any light on LDR) arduino automatically turns on the LED. 
  4. When we remove our hand on LDR. Arduino automatically Turns Off LED.


 

No comments

If you have any doubts, Please let me know