int LDR = A2;
int LED = 13;
int nilaiLDR = 0;
void setup() {
pinMode(LED, OUTPUT);
Serial.begin(9600);
}
void loop() {
nilaiLDR = analogRead(LDR);
Serial.print("nilaiLDR = ");
Serial.println(nilaiLDR);
if (nilaiLDR < 500) {
digitalWrite(LED, HIGH);
}
else{
digitalWrite(LED, LOW);
}
}