Trending

Street light using Arduino

Designing a system based on Arduino to control the street lights, turning on during the night and off during daylight.

Introduction- 

We are going to design an automatic street light system that turns on during night/dark and turns off during daylight. It uses an LDR to control the switch state.

An LDR is a light-dependent resistor whose resistance changes according to the light falling upon it.
The resistance increases with darkness and decreases with light.
An LDR.




Components required-

1. LDR 
2. Arduino 
3. LEDs 
4. 4.7 Kohm Resistor


Connections-  

1. Connect the pin 5 of Arduino to LED +ve and GND to -ve.
2. Connect 4.7K ohms resistor in series with LDR between 5V and GND.
3. Join A0 of Arduino to the middle node between LDR and resistor ( as shown in the schematic).

Circuit schematic - 


Arduino code- 


int ledpin=5;
int data;

void setup() {
 pinMode(5,OUTPUT);
 pinMode(A0,INPUT);
 Serial.begin(9600); 
}

void loop() {
  Serial.println("LED State-");
  data = analogRead(A0);
  if(data<200){
    digitalWrite(5,HIGH);
    Serial.println("ON");
  }
  else{
    digitalWrite(5,LOW);
    Serial.println("OFF");
  }
}



No comments