#CONTROLLING LED WITH
from machine import Pin, PWM, ADC
from time import sleep
ldr=ADC(Pin(14))
ldr.width(ADC.WIDTH_10BIT)
ldr.atten(ADC.ATTN_11DB)
frequency=5000
led = PWM(Pin(2),frequency)
while 1:
x=ldr.read()
print('LDR value=',x)
voltage = x *(3.3/1023)
print('Voltage is', voltage)
led.duty(1023-x)
sleep(0.5)