Skip to content

Commit ae9a07c

Browse files
authored
Merge pull request #5 from adafruit/rpi_simpletests
add rpi_matrixkeypad_simpletest.py with pin mappings for pi
2 parents cbe0474 + 12d277c commit ae9a07c

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

examples/matrixkeypad_simpletest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
# Membrane 3x4 matrix keypad - https://www.adafruit.com/product/419
77
cols = [digitalio.DigitalInOut(x) for x in (board.D9, board.D6, board.D5)]
88
rows = [digitalio.DigitalInOut(x) for x in (board.D13, board.D12, board.D11, board.D10)]
9+
910
# 3x4 matrix keypad - Rows and columns are mixed up for https://www.adafruit.com/product/3845
1011
# Use the same wiring as in the guide with the following setup lines:
1112
# cols = [digitalio.DigitalInOut(x) for x in (board.D11, board.D13, board.D9)]
1213
# rows = [digitalio.DigitalInOut(x) for x in (board.D12, board.D5, board.D6, board.D10)]
14+
1315
keys = ((1, 2, 3),
1416
(4, 5, 6),
1517
(7, 8, 9),
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import time
2+
import digitalio
3+
import board
4+
import adafruit_matrixkeypad
5+
6+
# Membrane 3x4 matrix keypad on Raspberry Pi -
7+
# https://www.adafruit.com/product/419
8+
cols = [digitalio.DigitalInOut(x) for x in (board.D26, board.D20, board.D21)]
9+
rows = [digitalio.DigitalInOut(x) for x in (board.D5, board.D6, board.D13, board.D19)]
10+
11+
# 3x4 matrix keypad on Raspberry Pi -
12+
# rows and columns are mixed up for https://www.adafruit.com/product/3845
13+
# cols = [digitalio.DigitalInOut(x) for x in (board.D13, board.D5, board.D26)]
14+
# rows = [digitalio.DigitalInOut(x) for x in (board.D6, board.D21, board.D20, board.D19)]
15+
16+
keys = ((1, 2, 3),
17+
(4, 5, 6),
18+
(7, 8, 9),
19+
('*', 0, '#'))
20+
21+
keypad = adafruit_matrixkeypad.Matrix_Keypad(rows, cols, keys)
22+
23+
while True:
24+
keys = keypad.pressed_keys
25+
if keys:
26+
print("Pressed: ", keys)
27+
time.sleep(0.1)

0 commit comments

Comments
 (0)