print("Hello, Photoresistor (LDR) sensor module")
print("Date: 29/11/2023")
print('Created by AHH')
# Import all libraries/Pin/time for this section
from machine import Pin,ADC
from utime import sleep
# Pin Declaration
LDR_Pin = ADC (Pin (12, Pin.IN))
# Coding Diagram
while True:
light_intensity_value = LDR_Pin.read () # For Analoge read and Digital value
print (light_intensity_value)
light_in_voltage = light_intensity_value / 4096*5.0 # the relationship between the illumination level (lux), resistance (R), and the voltage level
print ("The voltage detected base on light absorption is", light_in_voltage, "V")
if light_in_voltage >= 4.17:
led.off()
led.on()
sleep (3)