from utime import sleep
from machine import Pin, I2C
from lcd_api import LcdApi
from pico_i2c_lcd import I2cLcd
#creo pantalla
#___________________________________________________#
I2C_ADDR = 0x27 # Dirección del LCD
I2C_NUM_ROWS = 2 # Número de líneas del LCD
I2C_NUM_COLS = 16 # Número de caracteres por línea
# Raspberry Pi Pico
i2c = I2C(1, sda=Pin(26), scl=Pin(27), freq=400000) # Configuración del bus I2C
lcd = I2cLcd(i2c, I2C_ADDR, I2C_NUM_ROWS, I2C_NUM_COLS) # Inicialización del LCD
#___________________________________________________#
#creo leds
red = Pin(18, Pin.OUT)
blue = Pin(21, Pin.OUT)
green = Pin(28, Pin.OUT)
#creo botones
red_button = Pin(17, Pin.OUT, Pin.PULL_DOWN)
blue_button = Pin(16, Pin.OUT, Pin.PULL_DOWN)
green_button = Pin(19, Pin.OUT, Pin.PULL_DOWN)
while True:
lcd.clear()
lcd.move_to(1,0)
lcd.putstr("ALARMA")
lcd.move_to(2,2)
lcd.putstr("ESTADO ::")
if sensor.value() == 1:
rojo.value(1)
amarillo.value(0)
lcd.move_to(10,2)
lcd.putstr("INTRUSOS")
BOCINA.value(1)
else :
rojo.value(0)
amarillo.value(1)
lcd.move_to(10,2)
lcd.putstr("SEGURO")
sleep(1)
while True:
# Verifico si el botón verde está presionado
if green_button.value() == 1:
green.on()
else:
green.off()
# Verifico si el botón rojo está presionado
if red_button.value() == 1:
red.on()
else:
red.off()
# Verifico si el botón azul está presionado
if blue_button.value() == 1:
blue.on()
else:
blue.off()
sleep(0.1)