Automatic light

int LDR_Pin = A0; //analog pin 0
int LED = 11;
 
void setup(){
  pinMode(LED,OUTPUT);
  Serial.begin(9600);
}
 
void loop(){
  int LDRReading = analogRead(LDR_Pin); 
 
  Serial.println(LDRReading);
  if(LDRReading>600)
  {
    
    digitalWrite(LED,HIGH);
    delay(250);
     digitalWrite(LED,LOW);
     delay(250);
  }
  
  else if(LDRReading<600)
  {
    
   digitalWrite(LED,LOW); 
  }
   //just here to slow down the output for easier reading
}
//resister connected leg Ao,resister leg 5V,ldr free leg gnd!
This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free