There are eight general purpose IO pins on the 13*2 pin connectors of the Raspberrypi board and among them four pins has been selected as input and then remaining four pins as output. The input pins are connected to push button and are pulled down using 1K resistors. The output pins are connected to the LEDs through another set of 1K resistors. For this project the Raspberry pi board is loaded with Ubuntu and is remotely accessed using VNC. To access the pins that coming out of the Broadcom controller the C library “bcm2835” has been downloaded and installed.
Simple Raspberry Pi Game Pad for Ball Catching Game
This game contains four balls and the movement of which can be controlled with the help of the four keys in the gamepad. The game can be opened in a browser window and played with the help of four buttons connected to the pins of the Raspberry pi board. One has to install the browser “Iceweasel” which is the Debian version of the Firefox. The following commands can install the software on the Raspberry pi;
sudo apt-get update
sudo apt-get install iceweasel
The parent process here creates four child processes which are dedicated for each of the keys in the gamepad. Whenever a key is pressed or released, they will generate a signal and send it to the parent process with a value. This method of sending a signal with value helps the parent process to identify which key has been pressed or released.
The FIFO can also be created using the code itself by adding the function mkfifo(), open() as explained in a previous documentation.
The user can write data into the temporary file from the terminal itself using the ‘echo’ command as shown in the following example.
echo abcdef >> /tmp/my_fifo
The FIFO writing parent process is written in such a way that it will write some particular characters to the FIFO in respond to the signals received from the child processes. The commands that will be written to the FIFO for controlling the movement of the balls in the game are listed below;
u -> catch the ball in the first column
r -> catch the ball in the second column
l -> catch the ball in the third column
d -> catch the ball in the fourth column
These commands can be written into the FIFO with the help of the system() function.
For more detail: Simple Raspberry Pi Game Pad for Ball Catching Game