Prototyping a small counting game – pressing a button to count up to 5 with LEDs and on an OLED screen – then celebrating once reached.
My daughter loves to help me build simple circuits, turning LED lights on and off on a breadboard. Not yet grasping her 1-2-3’s or A-B-C’s, I thought building a small game would be an engaging way to get her learning with the things she likes.
To put this together I used the following setup:
- Raspberry Pi Zero WH w/ Raspberry Pi OS Lite
- Adafruit PiOLED – 128×32 Monochrome OLED
- 6x LEDs
- 8x M-F Jumpers
- 6x resistors
Wired as so:
By no means am I a Python developer, so I’m just swinging away here – the codes very repetitive, but hey, it does the trick easy enough.
Run the script with
python3 oled-count-game.py. If the script fails and you get a warning about missing modules, the modules can be installed usually with
sudo pip3 install <module_name>, for the GPIO if that’s missing, it can be installed with
sudo apt-get install python3-rpi.gpio --assume-yes.