const int ledPin = 13;
void setup() {
Serial.begin(9600);
pinMode(A0, INPUT);
pinMode(ledPin, OUTPUT);
}
void loop() {
int nilai = analogRead(A0);
if(nilai<=200){
digitalWrite(ledPin, HIGH);
Serial.print(nilai);
Serial.println(" ; Gelap ; LED menyala");
}
else{
digitalWrite(ledPin, LOW);
Serial.print(nilai);
Serial.println(" ; Terang ; LED mati");
}
}