ejemplo LCD1602

mail@pastecode.io avatar
unknown
python
2 years ago
778 B
5
Indexable
Never
from machine import Pin, I2C
import utime
from esp8266_i2c_lcd import I2cLcd

boton=Pin(3, Pin.IN, Pin.PULL_UP)
i2c=I2C(0, sda=machine.Pin(0),scl=machine.Pin(1),freq=400000)
lcd=I2cLcd(i2c,0x3f,2,16)

lcd.move_to(03,0)
lcd.putstr("Iniciando")
lcd.move_to(04,1)
lcd.putstr('sistema')
utime.sleep(2)
lcd.clear()

count=0
def pulsar(pin):
    global count
    count=count+1
    if(count >2):
        count=0
    if (count ==0):
        lcd.clear()
        lcd.move_to(03,0)
        lcd.putstr("Pedro")
    if (count ==1):
        lcd.clear()
        lcd.move_to(03,0)
        lcd.putstr("Pablo")
    if (count ==2):
        lcd.clear()
        lcd.move_to(03,0)
        lcd.putstr("!@#~½¬{[]}?¿")
        
boton.irq(handler=pulsar, trigger=Pin.IRQ_FALLING)
while True:
    pass