from machine import ADC, Pin, Timer
import time

LDR = ADC(Pin(13))
LED = Pin(19, Pin.OUT)

def fun(tim):
    print(LDR.read())
    if LDR.read()>2000:
        LED.value(1)
    else:
        LED.value(0)

tim = Timer(0)
tim.init(period = 500, mode = Timer.PERIODIC, callback = fun)