A small electronics project from Hacker News this week caught my eye: an LED matrix driven by the phyllotaxis equation — the same math that produces sunflower seeds and pinecone scales.
The Math
Phyllotaxis is deceptively simple:
for n in range(N):
angle = n * 137.5°
r = c * sqrt(n)
x = r * cos(angle)
y = r * sin(angle)
The 137.5° is the golden angle — the divergence angle that packs circles most densely without overlap. It's why sunflower seeds tile the way they do. The same equation applied to LED positions gives you a visually coherent pattern that feels organic.
The Circuit
- 8x8 LED matrix (WS2812B strip is easier to drive)
- Raspberry Pi Pico as controller ($4)
- 470Ω resistors on each LED if you want visible dimming
- 5V power, 2A supply for 64 LEDs at full brightness
The Code
import time, math
from pimoroni import RGBLED, RGBMatrix
matrix = RGBMatrix(8, 8, pin=0)
matrix.set_brightness(0.3)
GOLDEN = 137.50776405
for n in range(64):
theta = math.radians(n * GOLDEN)
r = 0.08 * math.sqrt(n)
x = int((r * math.cos(theta) + 0.5) * 8)
y = int((r * math.sin(theta) + 0.5) * 8)
if 0 <= x < 8 and 0 <= y < 8:
color = (n % 64, 128, 255 - n % 64)
matrix.set_pixel(x, y, color[0] // 4, color[1] // 4, color[2] // 4)
matrix.show()
time.sleep(0.1)
What I Learned
- Golden angle is the point. Swap 137.5° for anything else and you get a boring grid or a broken spiral.
- Sub-pixel dimming matters. The Pi Pico has 16-bit PWM, so brightness steps look smooth. 8-bit PWM is visible.
- Current draw surprises people. 64 LEDs at 20mA each = 1.28A. If you're on a Pi Pico W USB-C, you need external 5V power or it brownouts.
The Next Step
Animate the phyllotaxis — rotate the golden angle slowly and you get a growing sunflower on a chip. Combined with a real-time clock, you can have it grow during the day and shrink at night. Cheap ambient display, ~$10 total.
Get the AI Agent Automation Guide for the full electronics automation workflow: ggouai.gumroad.com/l/dyrvmg ($17).
Full source: ggouai.top












