from machine import Pin,PWM
from time import sleep
def LCD (x):
RS.value(int(x[8]))
D0.value(int(x[7]))
D1.value(int(x[6]))
D2.value(int(x[5]))
D3.value(int(x[4]))
D4.value(int(x[3]))
D5.value(int(x[2]))
D6.value(int(x[1]))
D7.value(int(x[0]))
EN.on()
sleep(0.1)
EN.off()
RS=Pin(25,Pin.OUT)
EN=Pin(23,Pin.OUT)
D0=Pin(22,Pin.OUT)
D1=Pin(21,Pin.OUT)
D2=Pin(19,Pin.OUT)
D3=Pin(18,Pin.OUT)
D4=Pin(5,Pin.OUT)
D5=Pin(4,Pin.OUT)
D6=Pin(2,Pin.OUT)
D7=Pin(15,Pin.OUT)
boton=Pin(12,Pin.IN,Pin.PULL_UP)
motor=PWM(Pin(26),freq=500)
#inicialización de la lcd
inicio =["001100000","001100000","001100000","001110000","000101000","000011000","000001100","000000010"]
baja=["000000100","010000101","010000011","010010101","010000011","000000100"]
media=["000000100","010011011","010001011","010001001","010010011","010000011","000000100"]
alta=["000000100","010000011","010011001","010101001","010000011","000000100"]
for i in inicio:
LCD(i)
var=0
while(1):
if boton.value() == 0:
sleep(0.1)
var+=1
if(var>3):
var=0
while(BOTON.value() == 0):
sleep(0.1)
if var == 0:
motor.duty(200)
for a in baja:
LCD(a)
sleep(0.1)
if var == 1:
motor.duty(250)
for b in media:
LCD(b)
sleep(0.1)
if var==2:
for c in alta:
LCD(c)
sleep(0.1)
motor.duty(300)