#Ejercicio 5: Control de ventilador inteligente por temperatura + botón de prioridad
#Nombre: Zhayanka Pilay Beltrán
import time
from machine import Pin
led_verde = Pin(0, Pin.OUT) # LED Verde (consumo bajo)
led_amarillo = Pin(4, Pin.OUT) # LED Amarillo (consumo medio)
led_rojo = Pin(9, Pin.OUT) # LED Rojo (consumo alto)
time.sleep(0.1) # Espera a que el USB esté listo
nombre = input ("Ingrese su nombre: ")
consumo = float (input("Ingrese el consumo en kwh: "))
tarifa = input ("¿Desea usar tarifa fija? (sí/no): "). lower()
if tarifa == "sí" or tarifa== "si":
tarifa= float(input("Ingrese la tarifa fija ($/kwh): "))
else:
if consumo < 100:
tarifa=0.12
elif consumo <= 500:
tarifa =0.15
else:
tarifa= 0.18
print("\n")
total =round (consumo*tarifa, 2)
print(" ********************")
print(" CNEL\n")
print(" ********************")
print("{:<20} {:<15} {:<15}".format("Nombre", "Consumo (kWh)", "Total a Pagar ($)"))
print("-----------------------------------------------------")
print("{:<20} {:<15} {:<15}".format(nombre, consumo, total))
print("===================================================\n")
if consumo <= 100:
led_verde.on()
led_amarillo.off()
led_rojo.off()
print("🟢 Consumo bajo")
elif consumo <= 500:
led_verde.off()
led_amarillo.on()
led_rojo.off()
print("🟡 Consumo medio")
else:
led_verde.off()
led_amarillo.off()
led_rojo.on()
print("🔴 Consumo alto")