int led1 = 11;
int led4 = 8;
int led3 = 5;
int led2 = 2;
int ldr = A0;
void setup() {
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(ldr, OUTPUT);
// put your setup code here, to run once:
}
void loop() {
int a = analogRead(ldr);
digitalWrite(ldr, HIGH);
if (a < 500)
{
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
Serial.println("led on");
delay(1000);
}
else
{
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
Serial.println("led off");
delay(1000);
}
// put your main code here, to run repeatedly:
}