from machine import Pin, ADC, Timer
from time import sleep
ldr = ADC(Pin(26))
ldr.atten(ADC.ATTN_11DB)
red = Pin(15, Pin.OUT)
yel = Pin(2, Pin.OUT)
gre = Pin(4, Pin.OUT)
buzzer = Pin(12, Pin.OUT)
while True:
lus = ldr.read()
print(lus)
if lus >= 3250 and lus <= 4063:
red.on()
yel.off()
gre.off()
elif lus >= 2031 and lus < 3250:
yel.on()
red.off()
gre.off()
elif lus < 2031:
yel.off()
red.off()
gre.on()
else:
gre.off()
red.off()
yel.off()
red.off()
gre.off()
yel.off()
sleep(0.5)