#define LDR A0
#define LED 8
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:
int Nilai_LDR = analogRead(A0);
Serial.print("Hambatan LDR : ");
Serial.println(Nilai_LDR);
delay(500);
if(Nilai_LDR <= 500){
digitalWrite(LED, HIGH);
}
else {
digitalWrite(LED, LOW);
}
}