#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
# Configuración de pines
LedR = Pin(0, Pin.OUT) # Rojo
LedA = Pin(2, Pin.OUT) # Amarillo
LedV = Pin(8, Pin.OUT) # Verde
boton = Pin(26, Pin.IN, Pin.PULL_DOWN)
tiempo_n= {'verde':5, 'amarillo':2, 'rojo': 5}
tiempo_r = {'verde':2, 'amarillo':1, 'rojo':5}
while True:
if boton.value() == 1:
print("Botón presionado - Ciclo acelerado")
tiempos = tiempo_r
else:
tiempos = tiempo_n
#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()