int Ledyellow = 21;
int Ledgreen = 18;
int LDR = 12;
int nilaiLDR = 0;
void setup(){
pinMode(Ledyellow, OUTPUT);
pinMode(Ledgreen, OUTPUT);
Serial.begin(9600);
}
void loop(){
nilaiLDR=analogRead(LDR);
Serial.print("Nilai LDR =");
Serial.println(nilaiLDR);
if (nilaiLDR > 500){
digitalWrite(Ledyellow,HIGH);
digitalWrite(Ledgreen,LOW);
}
else if (nilaiLDR < 500 ){
digitalWrite(Ledgreen, HIGH);
digitalWrite(Ledyellow,LOW);
}
}