- Learn Linux
- Learn Electronics
- Raspberry Pi
- LPI certification
- News & Reviews
Pygame Zero for Makers is a collection of resources to demonstrate how Pygame Zero can be used for Maker projects. This is designed for a Raspberry Pi, although can be used with other platforms. This includes using Pygame Zero as an alternative front end to electronic circuits, as well as how touch screens can be integrated into a maker project.
The overriding philosophy is that interfaces do not need to be boring.
These examples combine electronics connected to the Raspberry Pi with a fun graphical interface. The GPIO pins on the Raspberry Pi can be connected to various different electronic sensors or output devices, including LEDs, motors or a smoke generator. This is controlled using GPIO zero. The interface is a graphical inteface using virtual buttons and images which the user can interact with. This is created using Python Pygame Zero. The interface can be used with a touch screen (such as the offical Raspberry Pi touch screen) for a touch interface, or a regular screen using a mouse.
The worksheet example goes through simple switches and LEDs connected to the Raspberry Pi, but also show a bargraph, speedometer and how electronics in a 3D printed house can be controlled using Pygame Zero. This includes Christmas LEDs, a colour changing snowman and a smoke generator including in the building chimney. The building is created in approximately G-Scale so is suitable for use on an outdoor model railway. This is also included in the supplied source code.
The buttons used are created using Blender, but any other image files can be used. I've created a video tutorial to getting started with Blender.
The Pygame Zero for Makers worksheet was created for the UK 3D Printer meet-up 2019.
It is a hands on workshop that creates a graphical interface to control some simple electronics. This is used to create the electronics.py demonstration.
The worksheet is designed for use on a regular sized screen (minimum 800 x 600 pixels). The video example shows how it can be used for the Raspberry Pi touchscreen. Source code is included for both examples.
The rest of the code shows examples of how Pygame Zero can be used to make novel interfaces.
pgzero-demo.py - Provides a demonstration of creating buttons and LEDs which doesn't need any external electronics.
pgzero-demo-sml.py - Is a smaller version of the pgzero-demo. It is designed to fit onto the official Raspberry Pi 7inch touch screen.
bargraph.py - Shows a simple bargraph display similar to one you may use on a volume control display
bargraph-speed.py - Shows the bargraph alongside a speedometer type display. These show the same value, but damping is used on the speedometer to make if feel more natural.
house.py - provides a very different look to most other interfaces. In this case used to control the Raspberry Pi Christmas House that I used in an earlier project Model railway Christmas House project.
You may also be interested in the Space Asteroids game that I created using Pygame Zero and GPIO Zero along with images created in blender.
Please view the copyright information regarding use of the circuits.