Getting arty with a Pi
Tags: raspberrypi, art, python, maker
Published: 2023-04-22 15:32:58

This week I built a BrachioGraph (as mentioned in my [comment](https://dev.to/andypiper/comment/267a1) on ["What was your win this week?"](https://dev.to/devteam/what-was-your-win-this-week-4ld4)). 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0zxqkapvi7ip3idwylql.jpeg)

This is absolutely not my invention! I came across it in [the most recent issue of The MagPi magazine](https://www.raspberrypi.com/news/braciograph-a-raspberry-pi-powered-pen-plotter/), and immediately wanted to build one. The [BrachioGraph](https://brachiograph.art) was created and documented by **Daniele Procida**, all of [the code is on GitHub](https://github.com/evildmp/brachiograph), 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](https://wimbledonartfair.com) 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](https://dev.to/andypiper/building-a-compact-pi-cluster-1pia) 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](https://amzn.to/3H6aCsE) (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](https://www.brachiograph.art/tutorial/construct.html) 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](https://ceworkbench.wordpress.com/2019/07/09/setting-up-a-pi-zero-ethernet-gadget/) 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](https://www.printables.com/model/115161-rasberry-pi-zero-minimalist-mount/) 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c11u6lvg3x2277objq1o.jpeg)

- 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3sie4phepl69d4sitfb5.jpeg)

- 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](https://diode.zone/w/oTD6agqUmAbDUdbFNF5Ygp) (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! 😁️

{% embed https://diode.zone/videos/embed/b95ed6f4-e552-49f4-b3a0-15d03c1880ed %}

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](https://brachiograph.readthedocs.io/en/latest/tutorial/sophisticated-calibration/) 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 [Brachio.me](https://brachio.me/) 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](https://github.com/Findus23/BrachioGraph-Utils) 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tywoxyczpwe0ifovgarl.jpeg)

Feel free to look at what else we've been making in our [studio](https://forgeandcraft.co.uk), via Metapixl (it's a #Fediverse service, so you can follow [@forgeandcraft@metapixl.com](https://metapixl.com/@forgeandcraft) from your favourite Fediverse app or account).