#Ejercicio 1: Semáforo inteligente para cruce peatonal
#Nombre: Kevin Bermeo
#Fecha: 12/7/2025
import time
from machine import Pin
Rojo= Pin(2, Pin.OUT)
Amarillo = Pin(8, Pin.OUT)
Verde = Pin(13, Pin.OUT)
Peatonal = Pin(27,Pin.OUT)
def semaforo():
while True:
if Peatonal.value()==0:
Rojo.on()
Amarillo.off()
Verde.off()
time.sleep(5)
Rojo.off()
Amarillo.on()
Verde.off()
time.sleep(2)
Rojo.off()
Amarillo.off()
Verde.on()
time.sleep(5)
else:
print("Cruce Peatonal")
Rojo.on()
Amarillo.off()
Verde.off()
time.sleep(5)
Rojo.off()
Amarillo.on()
Verde.off()
time.sleep(1)
Rojo.off()
Amarillo.off()
Verde.on()
time.sleep(2)
# Llamamos a la función para iniciar el semáforo
semaforo()