DEV Community

Cover image for Getting arty with a Pi
Andy Piper
Andy Piper

Posted on

Getting arty with a Pi

This week I built a BrachioGraph (as mentioned in my comment on "What was your win this week?"). It's a simple pen plotter, driven by a Raspberry Pi - or, potentially, another single board computer - and some Python code.

A pen plotter with a logo drawn on paper

This is absolutely not my invention! I came across it in the most recent issue of The MagPi magazine, and immediately wanted to build one. The BrachioGraph was created and documented by Daniele Procida, all of the code is on GitHub, and it has been around for a number of years, since originally being introduced at a PyCon.

So... why build it? For fun; to learn; to put some hardware to use; and in preparation for a show that I'll be taking part in during May.

The basic things required are:

  • a single board computer. in this case I'm using a Pi Zero W v1.1 (I was able to replace the 4x Pi Zero W 1s in my Pi cluster-in-a-box with Pi Zero W 2s, so I had a few spare) - I realise that these boards in general are not the easiest to get hold of right now, but in principle other SBCs with GPIO pins that support Python 3 should work as well.
  • 3 simple SG90 servos, I picked up a set of 5 cheaply via Amazon UK (affiliate link). I might update these to something slightly more resilient later, but these work fine.
  • some small sticks, in the US they might be popsicle sticks, here in the UK we call them ice lolly sticks, but I just got a bag of them as "craft sticks" in the local hobby store, something like 50 for £1, so I'm well-equipped to build other things later ⚒️

That is pretty much it! The website has some really great instructions describing how to connect it all up, but I have a few notes of my own to throw in:

  • It has been a while since I played with a Pi Zero, and I wanted to get it set up without having to connect it to monitor, keyboard etc. I used the USB Ethernet Gadget method to install Raspberry Pi OS and then install the required packages without having to mess with any peripherals.

  • I wanted to make this somewhat reliable / reusable for events, so I've attached it to a sheet of mounting card. I used my 3D printer (of which more, sometime soon) to quickly print a small plate for the Pi Zero to sit on. The one I picked is great, as the Pi just clips in - I also used some nylon screws to anchor it down.

A Pi Zero W in a simple white mounting plate

  • for the wiring, I spliced some cables together and used heat-shrink to cover over the joins (the motors need to share the 5V and GND pins from the Pi).

A bundle of coloured wires connected to the Pi Zero GPIO pins

  • I found that a ball pen or biro is not the best option for drawing, as it can take a bit of pressure to engage the ink. I'm fortunate to share a space with an crafting enthusiast with a full set of stationery, so I'm using a Micron pen at the moment (I also have the advantage of different colours and tip sizes to choose from, and these use archival ink so it is a very nice result).

Although I play with a lot of gadgets, the excitement of having this all work (click through for video, since Forem doesn't want to let me embed from PeerTube) once I'd set everything up was still hard to ignore! 😁️

I'll note that the instructions lead you through calibration and adjustment, which is very helpful - but it can also be a bit tedious! Doing the "full sweep" adjustment to find the correct pulse variances for each angle took a while, and the code to drive and capture those is unforgiving (i.e. it crashes and you lose everything) if you tap in an invalid value by mistake, or drive the servos past their limits - I had to start over several times... 🤦🏻️

There's a site called that is super useful for converting images to the format to drive the BrachioGraph, and it also has an alternative version of a getting started tutorial. There are also useful community code examples, such as these utilities for handling SVGs and optimising plots. If you look around, you’ll probably find some other more sophisticated builds as well.

What's next? I'm off to convert lots of images for our event... and also to think about some code improvements and a web UI for my own BrachioGraph!

Me, as a plotter-drawn image

Feel free to look at what else we've been making in our studio, via Metapixl (it's a #Fediverse service, so you can follow from your favourite Fediverse app or account).

Top comments (1)

michaeltharrington profile image
Michael Tharrington

Oh heck yeah! Loving the BrachioGraph self portrait in the end. I'm (probably mistakenly) calling it a self portrait since you built the BrachioGraph. 😁