from machine import ADC,Pin,Timer
LDR = ADC(Pin(15))
GAMMA = 0.7
RL10 = 50
def fun(tim):
#print(LDR.read())
global GAMMA
global RL10
analongValue = LDR.read()
voltage = analongValue/4096.*5
resistance = 2000*voltage/(1 - voltage/5)
lux = pow(RL10*1e3*pow(10,GAMMA)/resistance,(1/GAMMA))
print(lux)
tim = Timer(1)
tim.init(period = 500,mode = Timer.PERIODIC,callback = fun)