Count to Pi
I wanted to make a fun game that could be used to see how many Digits of Pi can be memorized. This is the game I came up with using a Raspberry Pi Zero W, 16×2 lcd with an i2c backpack and a 4×3 Keypad.
To hold all the parts together nicely I designed an enclosure in Autodesk Fusion 360. I then milled it out on my Shapeoko. You could 3d print it also or just use a cardboard box.
Wiring it up
The keypad has 7 wires that will wire up to the GPIO pins.
- 1 to GPIO 14 (pin 08)
- 2 to GPIO 15 (pin 10)
- 3 to GPIO 23 (pin 16)
- 4 to GPIO 24 (pin 18)
- 5 to GPIO 8 (pin 24)
- 6 to GPIO 27 (pin 13)
- 7 to GPIO 22 (pin 15)
To connect the LCD Display with i2c Backpack we need to use a logic level converter since its 5v and the Pi prefers 3.3V, I followed this guide here.
Setting up the Pi Zero W
I used a Pi Zero W so I could easily ssh in to it and modify the code. But If you have a non wireless Pi zero that will work also.
For interfacing with the keypad we will use pad4pi which can be installed by running this command
sudo pip install pad4pi
We will then create a directory for our program
Then put the pi.py, pivalue.ini, and I2C_LCD_driver.py files in that folder.
We also then want to set it up to run the program at boot up automatically. The Pi foundation has some info on how to do it here but I had issues with there guide and did it a tad different.
To edit the rc.local file type
sudo nano /etc/rc.local
then scroll down to the bottom and put this in before exit 0.
cd /home/pi/countpi/ python pi.py & cd ..
Then press ctrl+x, say yes to saving. Now reboot the Pi and you should see it start automatically.
How to play
To power it I used a usb cable powered from my computer. When the Pi boots up the screen should say lets count to Pi. You can then start entering the digits of Pi, we skip the decimal though.
Read More: Count to Pi