Programming Examples

Arduino program to create automatic street light control by using LDR sensor


LDR sensor

Arduino program to create automatic street light control by using LDR sensor.

Automatic Street light Control is used to control the street lights (Turn on and off based on the light).  Here we make use of LDR (Light Dependent Resistor) and LED (Light Emitting diode) and Arduino.

Hardware Component Required :

  • LDR
  • LED
  • Resistor
  • Bread board
  • Connecting Wires
  • Arduino

Solution

void setup()
{
  pinMode(13,OUTPUT);
  pinMode(A0,INPUT);
  Serial.begin(9600);
}
void loop()
{
  	int signal;
  	signal=analogRead(A0);
  	Serial.println(signal);
  	if(signal<400)
    {  	
      	Serial.println("LED Light On");
      	digitalWrite(13,HIGH);  		
    }  	
  	else
    {
     Serial.println("LED Light OFF");
      digitalWrite(13,LOW);
   
    }
  delay(10);
}
Output/ Explanation:

Hear LDR is used to detect the light and Arduino is used to ON/OFF the LED Light

Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad