And once again, it might be best to break this problem into smaller pieces - start from a very simple tester setup:
* verify the pins/leads/whatever-connectors on the keypad with a multi-meter and mark them if possible as: column0 (left), column1 (center), column2 (right), row0 (top), row1, row2, row3 (if I understood the connector setup correctly)
* start python in interactive mode
- import gpio lib
- init gpio
- setup the pin connected to column0 as output
- setup the pin connected to row0 as input
- read the input + output result -> verify that low/off
- push the key 1 on the keypad down and repeat read -> should be high/on
- push other keys on the same column and row + read -> should be low/off
Then proceed designing the loops to test any key.
One most likely feasible trick to use, would be to name the outputs and inputs in your code - something like:
Code: Select all
column0 = <GPIO pin id for the one connected to col 0 here>
column1 = ...
column2 = ...
row0 = ...
row1 = ...
row2 = ...
row3 = ...
...
GPIO.setup(column0, GPIO.OUT)
...
GPIO.setup(row0, GPIO.IN)
...should make it easier to check/verify the setup!
When you get to the loops:
Code: Select all
columns = [column0, column1, column2]
rows = [row0, row1, row2, row3]
...
while True:
for curcol in columns:
GPIO.output(curcol, GPIO.HIGH)
for currow in rows:
inpval = GPIO.input(currow)
if inpval == GPIO.HIGH:
button_pressed = button_map[curcol, currow] # or something similar - so that if curcol == 0 and currow == 0, button_pressed = 1
...
(note that I haven't used RPi.GPIO, so some syntax errors more than likely, but should give the idea)
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'