#Proyecto: Semáforo inteligente para cruce peatonal
#Nombre: Zhayanka Pilay
#Fecha 04/07/25
import time
from machine import Pin
time.sleep(0.1) # Wait for USB to become ready
#Leds
LedR = Pin(0, Pin.OUT) # Rojo
LedA = Pin(2, Pin.OUT) # Amarillo
LedV = Pin(7, Pin.OUT) # Verde
boton = Pin(26, Pin.IN, Pin.PULL_DOWN)
tiempo_nor= {'verde':5, 'amarillo':2, 'rojo': 5}
tiempo_ra = {'verde':2, 'amarillo':1, 'rojo':5}
while True:
if boton.value() == 1:
print("Botón presionado - Ciclo acelerando")
tiempos = tiempo_ra
else:
tiempos = tiempo_nor
#Rojo
LedR.on()
LedA.off()
LedV.off()
print("Rojo Encendido")
time.sleep(tiempos['rojo'])
#Verde
LedR.off()
LedV.on()
print("Verde Encendido")
time.sleep(tiempos['verde'])
#Amarillo
LedV.off()
LedA.on()
print("Amarillo Encendido")
time.sleep(tiempos['amarillo'])
LedA.off()