from machine import Pin
from utime import sleep
row=(Pin(15,Pin.OUT),Pin(14,Pin.OUT),Pin(13,Pin.OUT),
Pin(12,Pin.OUT))
col=(Pin(11,Pin.IN,Pin.PULL_UP),Pin(10,Pin.IN,Pin.PULL_UP),
Pin(9,Pin.IN,Pin.PULL_UP))
label="123456789*0#"
def getkey():
val=0
for j in range (4):
for i in row:
i.value(1)
row[j].value(0)
for i in range(3):
if col[i].value()==0:
val=label[i+j*3]
sleep(0.1)
while col[i].value()==0:
pass
return val