Automatic Streetlights Using LDR

717

5

Introduction: Automatic Streetlights Using LDR

About: Hi I'm Engr. Panda :)

This is a simple Automatic Streetlights Using LDR and based on arduino. As long as the car passes the streetlights it will automatically ON and Off if its not. :D

Step 1: Items

*Some Popsicle stick

*cardboard(or any platform)

*LDR(light dependent resistor)

*LED(light emitting diode) i used white :)

*connecting wires (solid wires)

*resistor(4-100ohms)(4-10kohms)

Step 2: Circuit Diagram

1.) Mount the LDR to the breadboard then test the LDR value using the program serial monitor

2.) As soon as you have the desired value(value depends in light environment. i got a value of 100 for dark) time to put the LED to test it using the program.

Step 3: Program

1.) LDR pinout A5,A4,A3,A2

2.) LED pinout 2, 3, 4 , 5

3.) i assign sensorvalue as the stored value

Step 4: Code

1.) As the sensorvalue become less than 100 the LED is High(on), greater than 100 means LED is low(off)

int sensorPin1=A5; // select the input pin for LDR
int sensorPin2=A4; // select the input pin for LDRint sensorValue1=0; // variable to store the value coming from the sensorint sensorValue2=0; // variable to store the value coming from the sensorint sensorPin3=A3; // select the input pin for LDRint sensorPin4=A2; // select the input pin for LDRint sensorValue3=0; // variable to store the value coming from the sensorint sensorValue4=0; // variable to store the value coming from the sensor
int led1=2;int led2=3;int led3=4;int led4=5;
void setup() {Serial.begin(9600); //sets serial port for communicationpinMode(led1, OUTPUT);pinMode(led2, OUTPUT);pinMode(led3, OUTPUT);pinMode(led4, OUTPUT);}void loop() {ldr();if( sensorValue1<100){digitalWrite(led1, HIGH);}else{digitalWrite(led1,LOW);}
 if( sensorValue2<100){digitalWrite(led2, HIGH);}else{digitalWrite(led2,LOW);}
 if( sensorValue3<100){digitalWrite(led3, HIGH);}else{digitalWrite(led3,LOW);}
 if( sensorValue4<100){digitalWrite(led4, HIGH);}else{digitalWrite(led4,LOW);}}
void ldr(){sensorValue1=analogRead(sensorPin1); // read the value from the sensorSerial.println(1);Serial.println(sensorValue1); //prints the values coming from the sensor on the screendelay(50);
sensorValue2=analogRead(sensorPin2); // read the value from the sensorSerial.println(2);Serial.println(sensorValue2); //prints the values coming from the sensor on the screendelay(50);
sensorValue3=analogRead(sensorPin3); // read the value from the sensorSerial.println(3);Serial.println(sensorValue3); //prints the values coming from the sensor on the screendelay(50);
sensorValue4=analogRead(sensorPin4); // read the value from the sensorSerial.println(4);Serial.println(sensorValue4); //prints the values coming from the sensor on the screendelay(50);}

Share

    Recommendations

    • Creative Misuse Contest

      Creative Misuse Contest
    • Metalworking Contest

      Metalworking Contest
    • Fix It! Contest

      Fix It! Contest

    Discussions

    nydailynews.com, e-hentai.org, ehow.com, superuser.com, chron.com, lefigaro.fr, wikiwiki.jp, abcnews.go.com, php.net, nbcnews.com,