A while back I taught a label maker to draw. This is what happens next: another CrunchLabs kit lands on the desk and I open the firmware “just to look.” This one is the Sand Garden, a small kinetic sand table. A magnet under the tray drags a steel ball through fine sand, leaving a groove, and the whole thing runs on an Arduino Nano.
I wanted to give it some patterns of my own. The code was easy. The lesson was in the one pattern that didn’t.
It thinks in angles, not X and Y
The label maker was a cartesian plotter: move X, move Y. The Sand Garden is polar. A position is two numbers in motor steps: an angle around the tray and a radius out from the centre.
Adding a pattern turned out to be the same shape of problem as last time. A pattern is a function that, given where the ball is now, returns the next point to head for. The main loop calls it forever, and the firmware works out the shortest way round and drives both motors together. All I had to decide was where next. A rose curve is then a handful of lines:
theta += dTheta;
float rho = MAX_R_STEPS * fabs(cos(k * theta)); // rho = R * |cos(k*theta)|
target.radial = (int)rho;
target.angular = convertRadiansToSteps(theta);
The ones that worked
Three landed straight away. A rose, its petals diving to the centre and
back out. An epicycloid, the spirograph curve, which at R=5, r=3 draws a
clean five-pointed star. And a Lissajous figure, two perpendicular sines,
which at a 3:2 ratio makes that atom-like knot.

For the epicycloid and the Lissajous I work the point out in x and y and convert to polar, because those shapes are easier to reason about in cartesian. The rose is polar to start with, so it drops straight in.
The one it refused
Then I tried a phyllotaxis, the sunflower spiral: seeds placed every 137.5 degrees, the golden angle. On a screen it is gorgeous. In the sand it was a mess.

The reason is obvious once you see it. A sunflower is an arrangement of dots. The spiral only exists in your eye, in where the dots sit relative to each other. But a sand table cannot make dots. The ball is always in the sand, always dragging. Join the seeds in the order they are generated and you get a tangle of chords across the tray, nothing like a sunflower.
So I swapped it for a Maurer rose, which is the same idea turned inside out. You walk around a rose curve in fixed angular steps and join the points you land on with straight lines. It is defined by its chords, not by dots, which is exactly what a dragged ball is good at. The machine draws its web happily.

And then I left it running
There is one more thing, and it is the whole point of a sand table: it never stops. A closed curve like the rose finishes in a few seconds and then just retraces its own groove, which is a waste of a machine built to run for hours.
So I gave the patterns a small twist. Every time a figure closes, the next one starts a few degrees rotated from the last. The rose stops being a single flower and slowly fans open, each pass laying its petals a little further round than the one before, until they overlap into something closer to a lily.

I meant to run it for a minute to check it looked right. I left it going for a lot longer than that. There is a knob for how fast it turns, and at some point I noticed I had stopped tuning it and was just watching the sand.
The medium picks the maths
None of this is really about sand. The machine has as much say as the curve does. The label maker fed its tape forward, so its friezes had to run one way. The sand table never lifts its ball, so it wants continuous curves, not scattered dots. The phyllotaxis ignored that and turned to mush; the Maurer rose respected it, all straight chords, and drew cleanly.
The pack, rose and epicycloid and Lissajous and the Maurer rose that took the sunflower’s place, is on sr.ht.
Have comments or want to discuss this topic?
Send an email to ~bounga/bounga.org-discuss@lists.sr.ht