const int ldr = 34;
int adcVal ;
float voltage;
const int led = 27;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(led, OUTPUT);
}
void loop() {
delay(10);
adcVal = analogRead(ldr);
voltage = (float(adcVal)/4095)*3.3;
Serial.println(voltage);
if (voltage > 1.5) {
digitalWrite(led, HIGH); // Nyalakan LED
} else {
digitalWrite(led, LOW); // Matikan LED
}
}