print("\nHello, LDR SENSOR!")
from machine import Pin, ADC
from utime import sleep
LDR_Pin = ADC(Pin(12, Pin.IN))
led_merah = Pin(2, Pin.OUT)
while True :
light_intensity_value = LDR_Pin.read() #if using analog it using .read
print(light_intensity_value)
light_in_voltage = light_intensity_value / 4096 * 5.0
print("The voltage detected based on light absorption is", light_in_voltage, "V\n")
if light_in_voltage >= 4.17:
led_merah.on()
sleep(0.3)
led_merah.off()
sleep(0.4)
oled.text("TIME TO SLEEP")
oled.show()
sleep(3)