cardiograph-computer/python-microcontrollers/pi-pico/tests/pi-pico-keypad.py

20 lines
542 B
Python

# pi pico
import keypad
import board
keymatrix = keypad.KeyMatrix(
row_pins = (board.GP5, board.GP6, board.GP7, board.GP8),
column_pins = (board.GP9, board.GP10, board.GP11, board.GP12, board.GP13) )
keymap = {
15:"0", 16:"1", 17:"2", 18:"3", 19:"runhalt",
10:"4", 11:"5", 12:"6", 13:"7", 14:"step",
5:"8", 6:"9", 7:"A", 8:"B", 9:"addrdata",
0:"C", 1:"D", 2:"E", 3:"F", 4:"NA" }
while True:
event = keymatrix.events.get()
if event:
print(event.key_number, event.released, keymap[event.key_number])