Techatronic
Published

Automatic Street Light Control System With Arduino

This is an automatic street light control system in which the street light is turned on and off with the help of Ardunio.

IntermediateFull instructions provided2 hours6,471
Automatic Street Light Control System With Arduino

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
LED Light Bulb, Frosted GLS
LED Light Bulb, Frosted GLS
×1
SparkFun Qwiic Single Relay
SparkFun Qwiic Single Relay
×1
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
USB-A to B Cable
USB-A to B Cable
×1
Single Turn Potentiometer- 10k ohms
Single Turn Potentiometer- 10k ohms
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Code snippet #1

Plain text
 // 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      ");  
   }  
  }  

Code snippet #2

Plain text
 // 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      ");  
   }  
  }  

Code snippet #3

Plain text
 // 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      ");  
   }  
  }  

Code snippet #4

Plain text
 // 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      ");  
   }  
  }  

Github

https://github.com/arduino-libraries/LiquidCrystal

Credits

Techatronic

Techatronic

72 projects • 124 followers
Electronic engineer

Comments