from machine import Pin
from time import sleep
def lcd(x):
D0.value(int(x[0]))
D1.value(int(x[1]))
D2.value(int(x[2]))
D3.value(int(x[3]))
D4.value(int(x[4]))
D5.value(int(x[5]))
D6.value(int(x[6]))
D7.value(int(x[7]))
RS.value(int(x[8]))
E.value(1)
sleep(t)
E.value(0)
D0 = Pin(21, Pin.OUT)
D1 = Pin(19, Pin.OUT)
D2 = Pin(18, Pin.OUT)
D3 = Pin(5, Pin.OUT)
D4 = Pin(4, Pin.OUT)
D5 = Pin(2, Pin.OUT)
D6 = Pin(15, Pin.OUT)
D7 = Pin(12, Pin.OUT)
RS = Pin(23, Pin.OUT)
E = Pin(22, Pin.OUT)
PB1 = Pin(25, Pin.IN, Pin.PULL_UP)
PB2 = Pin(26, Pin.IN, Pin.PULL_UP)
t = 0.1
lcd("001100000")
lcd("001100000")
lcd("001100000")
lcd("001110000")
lcd("000101000")
lcd("000011000")
lcd("000001100")
lcd("000000010")
LISTA = ["110011001", "100011001", "000011011", "000011001","101011001", "000011011", "010011001", "001011001","000010101", "010000101", "100011001", "000010101","010000101", "010011001"]
while (1):
if PB1.value() == 1 and PB2.value() == 1:
for i in range(0, 8):
lcd(LISTA[i])
elif PB1.value() == 0 and PB2.value() == 1:
for i in range(8, 11):
lcd(LISTA[i])
elif PB2.value() == 0 and PB1.value() == 1:
lcd("110000001")
for i in range(11, 14):
lcd(LISTA[i])
else:
lcd("000000011")