Badge Challenge Build Part 5

In this post I will look at more of the console build.

A cheap keypad is a long way from a full console, style was my next mission, I wanted a metal solid keypad...

I went off to see my local tech scrap merchant, and found ATM style keypads at only $5 each.

A nice looking keypad

However the pinout of the new keypad was unknown, so some guess work was needed.

15 minutes with a multi-meter and it was clear how it all worked.

I expected a 4x4 matrix, it turned out to be two of 8x1 matrix, the 1 and to 10 pins being the common pins and to other 8 being the switched pins.

Keypad and Raspberry Pi

Raspberry Pi pinout

The keyboard scanning code looks like this:

def ScanKeyboard(inputpin):
        GPIO.output(3, False)
        GPIO.output(5, False)
        for I in [3,5]:
                GPIO.output(I, True)
                for J in [7,11,13,15,19,21,23,29]:
                        if GPIO.input(J):
                GPIO.output(I, False)

GPIO pins 3 and 5 and the common pins, we set one of them high and then check to switched pins (7,11,13,15,19,21,23,29) if no match then we check the other common pin.

Once we have done the scanning we set both common pins high so as to catch the next interrupt.

If I was to re-write this code, the for J loop could be removed as we get the inputpin with the function call, so we only need to test with the for I loop.


keypad scanning code