from machine import Pin
from time import sleep
count = 0
entry = Pin(34, Pin.IN)
exit = Pin(35, Pin.IN)
green = Pin(23, Pin.OUT)
red = Pin(21, Pin.OUT)
yellow = Pin(19, Pin.OUT)
blue = Pin(5, Pin.OUT)
green.on()
red.off()
yellow.off()
blue.off()
while True:
if entry.value() == 1:
if count < 15:
count += 1
print("Cars:", count)
yellow.on()
sleep(0.2)
yellow.off()
sleep(0.3)
if exit.value() == 1:
if count > 0:
count -= 1
print("Cars:", count)
blue.on()
sleep(0.2)
blue.off()
sleep(0.3)
if count == 15:
green.off()
red.on()
else:
green.on()
red.off()