This is how I read a 16 matrix membrane switch. All horizonal rows connected to PORTC 1,2,3,4 outputs. All vertical columns connected to PORTB 1,2,3,4 inputs held high by resistor network. This example just shows eight readings:
PORTC = 255 'MAKE SURE ALL OUTPUTS ARE HIGH
START:
LOW PORTC.1
PAUSE 1
IF PORTB.1 = 0 THEN ONE
IF PORTB.2 = 0 THEN TWO
IF PORTB.3 = 0 THEN THREE
IF PORTB.4 = 0 THEN FOUR
HIGH PORTC.1
PAUSE 1
LOW PORTC.2
PAUSE 1
IF PORTB.1 = 0 THEN FIVE
IF PORTB.2 = 0 THEN SIX
IF PORTB.3 = 0 THEN SEVEN
IF PORTB.4 = 0 THEN EIGHT
HIGH PORTC.2
Pauses are added to slow down the process. Without them we experienced intermittant problems (probably from capacitance in the membrane switch). Hope this helps.
Bookmarks