Hey guys, are you familiar with the working of an LDR that is a light-dependent resistor? Well in this blog we are using an LDR module to make an automatic light that can turn on and off automatically. We are using an Arduino UNO to operate the automatic street light control system. There is a problem associated with the street lights that they keep on during the daytime or early in the morning when there is no need for artificial (bulb) light. Sometimes the light from the sun is too bright especially in summers when the days are longer than night that you can clearly see the surroundings. So keeping this in mind we are developing this project. You can read the full article on our website as well.
How Does automatic street light Work?LDR module generates its output depending upon the light that falls on its upper surface. During the daytime, the sunlight falls on LDR so the AC bulbs are off, and after sunset, there is no source of bright light so the AC bulbs are turned on. By using this concept we can manage to save a sufficient amount of energy per day.
- Analog connection
- Digital connection
- Arduino UNO
- LDR sensor module
- Breadboard
- Jumper wires
- USB cable for uploading the code
- AC bulb
- Single-channel relay module
- 16×2 LCD
- 10K-ohm potentiometer
- Analog connection
- Digital connection
- Analog connection
// TECHATRONIC.COM
#include "LiquidCrystal.h"
LiquidCrystal lcd(8,7,6,5,4,3);
void setup()
{
Serial.begin(9600);
lcd.begin(16,2);
pinMode(12,OUTPUT); // Relay Module Pin connected to D12
digitalWrite(12,HIGH); // Relay Module Normaly High
}
void loop()
{
int val = digitalRead(A0); // LDR sensor output pin connected to A0
Serial.println(val); // see the value in serial mpnitor in Arduino IDE
delay(100);
if(val > 300 )
{
digitalWrite(12,LOW); // Relay ON
lcd.setCursor(0,0);
lcd.print(" Evening Time ");
lcd.setCursor(0,1);
lcd.print(" Bulb ON ");
}
else
{
digitalWrite(12,HIGH); // Relay OFF
lcd.setCursor(0,0);
lcd.print(" Morning Time ");
lcd.setCursor(0,1);
lcd.print(" Bulb OFF ");
}
}
- Digital connection
// TECHATRONIC.COM
#include "LiquidCrystal.h"
LiquidCrystal lcd(8,7,6,5,4,3);
int val = 0 ;
void setup()
{
Serial.begin(9600);
lcd.init();
lcd.backlight();
s1.attach(9);
pinMode(2,INPUT); // LDR sensor output pin connected to D2
pinMode(12,OUTPUT); // Relay Module Pin connected to D12
digitalWrite(12,HIGH); // Relay Module Normaly High
}
void loop()
{
val = digitalRead(2); // LDR sensor output pin connected
Serial.println(val); // see the value in serial mpnitor in Arduino IDE
delay(100);
if(val == 0 )
{
digitalWrite(12,LOW); // Relay ON
lcd.setCursor(0,0);
lcd.print(" Evening Time ");
lcd.setCursor(0,1);
lcd.print(" Bulb ON ");
}
else
{
digitalWrite(12,HIGH); // Relay OFF
lcd.setCursor(0,0);
lcd.print(" Morning Time ");
lcd.setCursor(0,1);
lcd.print(" Bulb OFF ");
}
}
We hope you like this project and if so, please try to make it on your own. You can check tutorials on Arduino and Raspberry Pi written by us.
HAPPY LEARNING!
Comments
Please log in or sign up to comment.