#Ejercicio 3: Acceso seguro con verificación + intento limitado + tiempo debloqueo
#Nombre: Zhayanka Pilay
import time
from machine import Pin
boton=Pin(27,Pin.IN, Pin.PULL_DOWN)
claveok= "134340"
intentos=0
#Led
Ledv = Pin(0, Pin.OUT) # Verde: acceso
Ledr = Pin(2, Pin.OUT) # Rojo: fallo
Leda = Pin(7, Pin.OUT) # Amarillo: bloqueo
while True:
print("Presione el botón")
while not boton.value():
time.sleep(0.1)
clave = input("Ingrese la clave: ")
if clave==claveok:
print ("Acceso correcto")
Ledv.value(1)
Ledr.value(0)
Leda.value(0)
time.sleep(3)
Ledv.value(0)
intentos = 0
break
else:
intentos=intentos+1
print("Clave incorrecta \n")
Ledr.value(1)
time.sleep(0.5)
Ledr.value(0)
if intentos==3:
print("Acceso bloqueado por 10 segundos \n")
Leda.value(1)
for i in range(10, 0, -1):
print(f"Bloqueo: {i} segundos restantes")
time.sleep(1)
Leda.value(0)
intentos = 0