#write micropy script to interface an ldr with gpio14 of esp32 to do the following read the data form ldr print it on shell , calibirate the vol provided by ldr, control the led connected to gpio2 of esp32 (if sun led off no sunlight led on),control the birghtness of led with respect to the intencity of ldr
from machine import ADC, Pin,PWM
from time import sleep
ldr=ADC(Pin(14))
led_PWM=PWM(Pin(12),5000)
ldr.atten(ADC.ATTN_11DB)
while True:
ldr_value=ldr.read()
ldr_vol=ldr_value*(3.3/4095)
print("LDR value: ",ldr_value)
print("LDR voltage: ",ldr_vol,"v")
led_PWM.duty(round(ldr_value/4))
sleep(0.005)