import time
from machine import Pin
row_idx = [0, 1, 2, 3]
col_idx = [15, 14, 13, 12]
row_pins = []
col_pins = []
for i in range(4):
row_pins.append(Pin(row_idx[i], Pin.OUT, Pin.PULL_DOWN))
for i in range(4):
col_pins.append(Pin(col_idx[i], Pin.IN, Pin.PULL_DOWN))
print(row_pins)
print(col_pins)
symbol_table = [['1', '2', '3', 'A'], ['4', '5', '6', 'B'], ['7', '8', '9', 'C'], ['*', '0', '#', 'D']]
def key_scan():
for r in range(4):
row_pins[r].high()
for c in range(4):
if col_pins[c].value()==1:
print(symbol_table[r][c])
row_pins[r].low()
while True:
key_scan()
time.sleep(0.13)