We bought a 3D printer in 2025, and my daughter was fascinated by how it prints layer by layer. I suggested we build a simplified version of a printer: a CNC drawing machine. These projects are very popular on MakerWorld, Printables, and Thingiverse. The machines use stepper motors to move a pen along two fixed axes and a servo to lower and lift the pen.
Our favorite is the version from DIYMachines.co.uk for its reliability, simple parts, and detailed tutorial. While there are versions you can build with 3D-printed rails, we found that spending extra time and money on metal rails gives much better precision and repeatability. The total cost of the build is around $100. If you'd rather skip the build and buy a ready-made machine, they cost about twice as much on Amazon.

You can follow the detailed build instructions on DIYMachines to build your own. Our one hardware modification was plugging the Arduino into a Raspberry Pi Zero 2 W, which hosts the web app. This way, any device in the house with a web browser can print its own drawing.

The machine is nowhere near as high-resolution as a normal printer, but it's mesmerizing to watch. Perhaps printer companies should make transparent printers so people can see the inner workings.
The web app takes a picture, converts it into an outline, and generates G-code for the Arduino to run.

A few days later, after all of the kids' drawing requests had been fulfilled, I decided to turn the machine into a carnival caricature artist using generative image models and the CNC plotter. This way, we can make customized keepsakes at school fairs.
The caricature feature takes any picture, isolates the subject, and sends it to an image model API to turn it into a caricature. The caricature is then fed into the outline generator to produce G-code. I left the prompt in a playground tab for folks to play with.

How it works
A pen plotter can't print pixels. All it can do is move a pen in a straight line with the pen up or down. So the web app's job is to turn a picture into a list of pen strokes, then into G-code the Arduino understands. I added a Pipeline page to the app that shows the picture after every step if you want to see it in action.
From picture to lines
First, the picture gets turned into pure black and white. Anything darker than a threshold becomes ink and everything else becomes paper.
The obvious next step is to trace the outline of every black shape. The problem is that one line in the drawing turns into two lines on paper, one along each edge. What you really want is the line running down the middle of each stroke, called the centerline.
To find it, the app uses a thinning algorithm called Zhang-Suen. It peels pixels off the edges of every stroke, layer by layer like an onion, until only a line one pixel wide is left. The app then walks along this skeleton from each line end or intersection to the next one, turning it into paths.
Those paths are jagged because they follow every pixel. The app drops points that don't change the shape much (Ramer-Douglas-Peucker) and rounds off the corners (Chaikin smoothing), so the pen draws smooth curves instead of tiny staircases. Specks and little stubs get thrown out.
The pen is only 0.7mm wide, so thick lines need extra work. The app measures how far every black pixel is from the nearest white pixel, which tells it how thick each stroke is. Thick lines get a few passes side by side. Big filled areas, like pupils, get filled in with rings that shrink toward the middle, like contour lines on a map.
Planning the route
Lifting the pen is slow. The servo has to move, the pen has to settle, and the carriage has to travel to the next spot. So the app tries to lift the pen as little as possible:
- Paths with ends almost touching (less than 0.6mm apart) get joined into one.
- After finishing a stroke, the plotter goes to whichever stroke is closest. It's a quick, good-enough answer to the traveling salesman problem.
- If the jump to the next stroke stays on black the whole way, the pen just stays down. You can't tell the difference on paper.
Talking to the Arduino
Each stroke becomes a few lines of G-code: pen up, move to the start, pen down, then draw to each point along the way. The Arduino runs GRBL, an open-source firmware that reads G-code and drives the stepper motors. The Pi sends the G-code over USB and keeps GRBL's tiny 128-byte buffer full so the motors don't stutter between lines.
How the caricatures work
The caricature mode sends the photo to OpenAI's image model with a prompt asking for black line art on a white background, with no shading and no background. The prompt is what removes the background. You can choose how exaggerated the features are and whether to draw just the head or the head and shoulders.
The image that comes back gets cleaned up (specks removed, lines thickened a little) and then goes through the same steps as any other picture.
Recommendation
Here's my experience building the machine with the kids:
| Build & Setup | |
|---|---|
| Build time | 3–5 hours (plus ~8 hrs printing) |
| Tooling required | Allen keys, small screwdriver |
| Parts availability | Yes — Amazon / AliExpress |
| Instructions quality | ⭐⭐⭐⭐⭐ |
| Community support | ⭐⭐⭐⭐ |
| Cost | $$ |
| Entertainment Value | |
|---|---|
| Age rating | 6+ |
| Frustration Index | 😒 |
| Wow factor | 🤩🤩🤩🤩🤩 |
| Cooperative Play | 🤗🤗🤗 |
| Replay value | 🤗🤗🤗🤗🤗 |
| Education Value | |
|---|---|
| Hackability | 🪛🪛🪛🪛🪛 |
| Reusability of components | ⭐⭐⭐⭐ |
Concepts learned: Stepper motors, servos, Cartesian coordinates, G-code, image-to-outline conversion, hosting a web app on a Raspberry Pi, generative image models
Get started
Ready to build? Head over to DIYMachines for the parts list and full tutorial: