from machine import Pin
from time import sleep
D0 = Pin(23, Pin.OUT)
D1 = Pin(22, Pin.OUT)
D2 = Pin(21, Pin.OUT)
D3 = Pin(19, Pin.OUT)
D4 = Pin(18, Pin.OUT)
D5 = Pin(17, Pin.OUT)
D6 = Pin(16, Pin.OUT)
D7 = Pin(15, Pin.OUT)
RS = Pin(5, Pin.OUT)
EN = Pin(4, Pin.OUT)
B1 = Pin(26, Pin.IN,Pin.PULL_UP)
B2 = Pin(27, Pin.IN,Pin.PULL_UP)
def LCD(x):
D7.value(int(x[0]))
D6.value(int(x[1]))
D5.value(int(x[2]))
D4.value(int(x[3]))
D3.value(int(x[4]))
D2.value(int(x[5]))
D1.value(int(x[6]))
D0.value(int(x[7]))
RS.value(int(x[8]))
EN.on()
sleep(0.01)
EN.off()
ini = ["001100000","001100000","011000000","001110000","000101000","000011000","000001100","000000010"]
nombre=["000000010","010001101","010001011","010100101"]
fecha=["001100111","001100001","001011111","001100001","001100011","001011111","001100101","001100001","001100101","001101101"]
mensaje=["010010001","010011111","010011001","010000011"]
for i in ini:
LCD(i)
while(1):
if B1.value()==1 and B2.value()==1:
LCD("000000010")
for i in fecha:
LCD(i)
sleep(0.25)
elif B1.value()==1 and B2.value()==0:
for i in nombre:
LCD(i)
sleep(0.25)
elif B1.value()==0 and B2.value()==1:
LCD("110000000")
for i in mensaje:
LCD(i)
sleep(0.25)
else:
LCD("000000010")
sleep(0.25)