byte ldr = A5;
byte led = 9;
int nilai;

void setup() {
  Serial.begin(9600);
  pinMode(led, OUTPUT);
}


void loop() {
  // put your main code here, to run repeatedly:
nilai = analogRead(ldr);
Serial.print("Nilai LDR : ");
Serial.println(nilai);

if(nilai < 500){
  digitalWrite(led, HIGH);
  Serial.println("keadaan gelap lampu menyala");
}else if (nilai > 500){
  digitalWrite(led, LOW);
  Serial.println("keadaan terang lampu mati");
}
delay(1000);
}