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

void setup() {
  // put your setup code here, to run once:
  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 Akan Menyala");
  }else{
    digitalWrite(led, LOW);
    Serial.println("Keadaan Terang, Lampu Akan Mati");
  }
  delay(1000);
}