Getting ready

Perform the following steps to install uInput:

  1. First, we need to download uInput.

You will need to download the uInput Python library from GitHub (~50 KB) using the following commands:

wget https://github.com/tuomasjjrasanen/python-uinput/archive/master.zip
unzip master.zip
  

The library will unzip to a directory called python-uinput-master.

  1. Once completed, you can remove the ZIP file using the following command:
rm master.zip  
  1. Install the required packages using the following commands (if you have installed them already, the apt-get command will ignore them):
sudo apt-get install python3-setuptools python3-dev
sudo apt-get install libudev-dev  
  1. Compile and install uInput using the following commands:
cd python-uinput-master
sudo python3 setup.py install  
  1. Finally, we load the new uinput kernel module using the following command:
sudo modprobe uinput  

To ensure it is loaded upon startup, we can add uinput to the modules file using the following command:

sudo nano /etc/modules  

Put uinput on a new line in the file and save it (Ctrl + X, Y).

  1. Create the following circuit using the following equipment:
    • Breadboard (half-sized or larger)
    • 7 x DuPont female-to-male patch wires
    • Six push buttons
    • 6 x 470 ohm resistors
    • Breadboarding wire (solid core)
GPIO keypad circuit layout

The keypad circuit can also be built into a permanent circuit by soldering the components into a Vero prototype board (also known as a stripboard), as shown in the following photo:

GPIO keypad Pi hardware module
This circuit is available as a solder-yourself kit from PiHardware.com.
  1. Connect the circuit to the Raspberry Pi GPIO pins by matching the appropriate buttons with the appropriate pins, as shown in the following table:

Button

GPIO pin

GND

6

v

B_DOWN

22

<

B_LEFT

18

^

B_UP

15

>

B_RIGHT

13

1

B_1

11

2

B_2

7