STEAM night nametag plotter
This repo contains the code used to build an elementary school STEAM night activity.
- Kids entered text (such as their names) into a web-based app
- They chose to use the font they got automatically, or could click a button to select a new random choice
- Once happy, they hit "print it"
- They'd move to the Pen Plotter (the Axidraw V3) and select a pen
- They'd then hit a button on a USB gamepad to actually start their plot
The system worked really well!
The code is very "scrappy" -- it worked well enough for a live demo but, for example, the gamepad identifier is hard coded.
It works using a
fonts/ directory, which is not included, but can be populated by any font files opentype is aware of.
I downloaded the Google Fonts Archive and used that.
There's a simple script called
public/fonts which will
- find all the .ttf files in a tree, skipping any duplicates
- copy them into fonts/
- output an
all.jsonfile which has a list of all the fonts
This can then be loaded by the frontend and used to randomly select fonts to use.
When "Print It" gets pressed, the image is POSTed to a local server.
The backend server is a very simple python Flask app.
It takes the data written to it, and writes it to a local directory. The end.
The printer daemon:
- Waits for the click of a gamepad button
- Finds the oldest file (by creation time) in the directory the backend saves files to
- Sends that to the plotter
- Moves it to a
- Goes back to waiting for another gamepad click.
It was suprisingly tricky to get python to read the joystick on macos. I ended up having to use a low level HID (Human Interface Device) driver called hidapi.
$ brew install hidapi $ pip install hid
Since it found all the HID devices, I had to find the one that had
2axes in the
This script will almost certainly need tweaking if you'd like to use it.
One fun thing, because of the lazy way of blocking on input device, if you try and Control-C the program, it won't die. You need to hit Control-C and then tap a button. Control flow will return to the program and it'll exit.
For controlling the axidraw itself, I'm using the official axidraw python library.