#r1=d1
#r2=15
#r3=2
#r4=0
#c1=4
#c2=16
#c3=17
#c4=4
from machine import Pin
import utime
matrix_key=[["1", "2", "3","A"],
["4", "5", "6","B"],
["7", "8", "9","C"],
["*", "0", "#","D"]]
key_row=[1, 15, 2, 0]
key_col=[4, 16, 17, 4]
col_pin=[]
row_pin=[]
for button in range(0, 4):
row_pin.append(Pin(key_row[button], Pin.OUT))
row_pin[x].value(1)
col_pin.append(Pin(key_col[button], Pin.IN, Pin.PULL_DOWN))
col_pin[x].value(0)
print("Please Enter a key")
def scanning():
for row in range(4):
for col in range(4):
row_pin[row].on()
key=None
if col_pin[col].value()==1:
print("Pressed", matrix_key[row][col])
keypress=matrix_key[row][col]
utime.sleep(0.3)
row_pin[row].off()
while True:
scanning()