#write a micropython script to control the brightness of led conncted to GPio 4
#wrt to the intensity of the light falling on the ldr connected to gpio34(if the
#insenty of sunlight is more brightness of led should be MORE)
from machine import Pin, PWM, ADC
from time import sleep
led = PWM(Pin(4), 5000)
ldr = ADC(Pin(34))
ldr.width(ADC.WIDTH_10BIT)
ldr.atten(ADC.ATTN_11DB)
while True:
ldr_value = ldr.read()
inverted_brightness = 1023 - ldr_value
print("LDR Value:", ldr_value)
print("Inverted Brightness:", inverted_brightness)
led.duty(inverted_brightness)