Creating an automatic street light project using an Arduino Uno is a simple and fundamental task. The LDR sensor incorporated in the project is responsible for detecting light levels. This project is particularly beneficial for countries like India, where a significant amount of electricity is wasted due to street lights being left on during the day.
Circuit Diagram :-
Project Code :-
/*
LDR sensor
BY Arduino Techy
*/
#include<SoftwareSerial.h>
int sensorPin=A2;
int sensorValue = 0;
int led = 2;
void setup() {
pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop() {
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);
if(sensorValue < 1000)
{
Serial.println("LED light on");
digitalWrite(led,HIGH);
}
else {
Serial.println("LED light off");
digitalWrite(led,LOW);
delay(sensorValue);
}
}
Components :-
Resistors
Buying Link -https://amzn.to/3PXxVcs
Jumper Wires
Buying Link -https://amzn.to/3VUfWY7
Note :-
If you are using LDR sensor then follow the circuit diagram given, If you are using LDR module then connect it's vcc to 5v, GND to GND and Signal pin to A2.