from machine import Pin, ADC, Timer
L1 = Pin(23, Pin.OUT)
L2 = Pin(22, Pin.OUT)
L3 = Pin(21, Pin.OUT)
adc = ADC(Pin(32))
def tim(x):
valor = adc.read()
print(valor)
if valor <= 170:
L1.on()
L2.off()
L3.off()
elif valor <= 341:
L1.off()
L2.on()
L3.off()
else:
L1.off()
L2.off()
L3.on()
t0 = Timer(0)
t0.init(period=500, mode=Timer.PERIODIC, callback=tim)
adc.width(ADC.WIDTH_9BIT)
adc.atten(ADC.ATTN_11DB)
while(1):
pass