from machine import Pin
from time import sleep
teclas= [['1', '2', '3', 'A'],
['4', '5', '6', 'B'],
['7', '8', '9', 'C'],
['*', '0', '#', 'D']]
linhas= [Pin(pinos, Pin.OUT) for pinos in (7,6,5,4)]
colunas= [Pin(pinos, Pin.IN, Pin.PULL_DOWN) for pinos in (3,2,1,0)]
def teclado():
for i in range(4):
for linha in linhas:
linha.value(0)
linhas[i].value(1)
for x in range(4):
if colunas[x].value() == 1:
while colunas[x].value() == 1:
sleep(0.01)
return teclas[i][x]
def ver_tecla():
tecla= teclado()
if tecla:
print(f"a tecla presionada foi:{tecla}")
while True:
ver_tecla()