#define light_Sensor A0 // cant do space between words
void setup() {
pinMode (9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(light_Sensor, INPUT);
Serial.begin(9600);
}
void loop(){
int lightLevel = analogRead(light_Sensor); Serial.println(lightLevel);
if(lightLevel <= 255){ // 1023 / 4 = 225
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,HIGH);
}
else if(lightLevel <= 510 && lightLevel >= 255){ // 225*2 = 510
digitalWrite(9,HIGH);
digitalWrite(10,HIGH);
digitalWrite(11,LOW);
}
else if(lightLevel <= 765 && lightLevel >= 510){ // 225*3 = 765
digitalWrite(9,HIGH);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
}
else if(lightLevel <= 1023 && lightLevel >= 765){ // 225*4 = 1023
digitalWrite(9,LOW);
digitalWrite(10,LOW);
digitalWrite(11,LOW);
}
}
in short (just 3 leds) this is it.
u need to put the curect time (lightLevel <= 510 && lightLevel >= 255) and that it
i didnt change so much of ur code.
now just add 3 more leds, goos luck