creative coding

From Sunflower Geometry to Sound: Building an Audio-Reactive LED Sculpture

From Sunflower Geometry to Sound: Building an Audio-Reactive LED Sculpture

A sunflower hiding in a few lines of code

A dark wall, a circle of translucent cells, and light moving outward like a slow ripple. At first glance, an audio-reactive LED sculpture like this feels organic rather than engineered. Look closer, though, and every glowing point has a coordinate, every cell has a boundary, and every pulse comes from a small piece of mathematics.

The design puzzle is clear: how do you turn a sunflower pattern into a display that listens?

Start with phyllotaxis

Phyllotaxis describes the arrangement of repeated botanical elements around a center or stem. Sunflower florets, pinecone scales, and the leaves of many plants often form a spiral pattern related to the golden angle, an angular step of about 137.507 degrees. That turn is an irrational fraction of a full rotation, so new points avoid repeatedly stacking along the same few spokes. (nature.com)

A compact point generator is enough to create the first version of the pattern:

const float golden_angle = 2.39996323f; // radians

for (int i = 0; i < count; ++i) {
 float u = (i + 0.5f) / count;
 float radius = u * outer_radius;
 float angle = i * golden_angle;

 points[i].x = cosf(angle) * radius;
 points[i].y = sinf(angle) * radius;
}

Some implementations multiply the index by 1.6180339887 in turns instead. Since a whole turn disappears when sine and cosine are evaluated, that produces the same family of points with the spiral winding in the opposite direction.

The linear radius in this example gives the sculpture a strong visual pull from the center. For a more even density across the disk, replace u with sqrtf(u). That small change matters because the area of a circle grows faster than its radius. For an artwork, though, the best formula is the one that produces the feeling you want.

From points to physical cells

The points are only seeds. To turn them into compartments, generate a Voronoi tessellation, a partition in which every location belongs to the nearest seed point. Each polygon becomes a cell around one LED, producing the seed-pod appearance that makes the pattern feel botanical rather than like a regular pixel grid. (arxiv.org)

The geometry can then move from a Processing sketch into Python with CadQuery. CadQuery is a code-driven computer-aided design tool: instead of drawing every wall by hand, you describe the shape with operations that can be repeated and parameterized. A negative offset2D shrinks each polygon inward, extrude gives it height, and cut performs the CAD equivalent of carving one solid out of another. (cadquery.readthedocs.io)

cell = (
 cq.Workplane("XY")
.polyline(vertices)
.close
.offset2D(-wall_thickness / 2, kind="intersection")
.extrude(total_height)
.translate((0, 0, base_height))
)

body = body.cut(cell)
body = body.cut(led_hole.translate((center_x, center_y, 0)))

The result is not one large printed disk with lights attached afterward. It is a shell whose walls already understand the pattern. Splitting that shell into four quadrants makes the design fit on a desktop printer, while screw holes and a thin faceplate turn the printed parts into something that can be assembled and serviced.

The diffuser is just as important as the plastic. Fibrous mulberry paper softens the individual LEDs and lets neighboring cells visually blend together. A routed bamboo backplate adds structure without fighting the plant-like geometry. The paper is not a finishing touch; it is part of the optical design.

Give the sculpture a coordinate system

An addressable RGB LED is a pixel that receives data and can display its own color. The LEDs may be wired in a long chain, but the animation does not need to think in chain order. Store each LED's normalized x and y position in a lookup table, then render patterns from those coordinates.

That makes the firmware feel more like a tiny graphics engine. The following function uses polar coordinates, where r is distance from the center and theta is the angle around it:

void radial_wave(LEDBuffer leds, float seconds) {
 for (int i = 0; i < NUM_LEDS; ++i) {
 float x = led_positions[i][0];
 float y = led_positions[i][1];

 float r = sqrtf(x * x + y * y);
 float theta = atan2f(y, x);

 float wave = 0.5f + 0.5f * sinf(
 r * 5.0f + theta * 2.0f - seconds * 2.0f
 );

 uint8_t level = (uint8_t)(wave * 255.0f);
 leds[i] = rgb(level, 0, level / 5);
 }
}

This is shader-like code: a small function calculates the color of every pixel for the current moment. It does not need a graphics processor. The important idea is that the animation follows the sculpture's actual geometry, so a radial wave remains radial even though the LEDs are arranged in irregular polygons.

Make light respond to sound

A repeating animation already gives the display motion. Audio gives it a reason to change.

The microphone used in this kind of build can be a digital MEMS microphone such as the INMP441. It includes signal conditioning and an analog-to-digital converter, then sends audio samples through an I²S interface, a serial bus designed for digital audio. That means the microcontroller receives digital samples directly instead of first needing an analog preamplifier and separate codec. (invensense.tdk.com)

The audio loop is a short pipeline. Capture a block of samples, apply a window to reduce edge artifacts, run a Fast Fourier Transform, or FFT, and measure how much energy appears in different frequency ranges. An FFT changes a short recording from the time domain—how the waveform changes moment by moment—into frequency bins that reveal bass, midrange, and treble activity.

A Cortex-M4-based STM32 has digital signal-processing instructions and may include a floating-point unit. ARM's CMSIS-DSP library provides optimized transform functions, including real-input FFT routines, which makes this kind of analysis practical on a small embedded board. (st.com)

The raw spectrum is usually too jumpy to drive a beautiful sculpture directly. Auto-gain keeps a quiet room from looking dead and a loud song from staying permanently saturated. Smoothing prevents every sample from becoming a nervous flicker. From there, bass energy can expand a central pulse, midrange can alter the spiral's speed, and high frequencies can add brief accents around the perimeter.

The unglamorous lesson: wiring matters

The first electronics prototype used a perfboard and became sensitive to movement. LEDs flickering when an enclosure shifts can look like a software bug, but the cause is often signal integrity, power distribution, or a loose ground.

A 3.3-volt microcontroller may also need a logic-level shifter when it drives LEDs powered at 5 volts. The shifter translates the data signal into a voltage range the pixels can reliably recognize. A short data path, a shared ground, suitable power buffering, and a resistor near the first pixel all make the final installation less temperamental. (learn.adafruit.com)

Moving from perfboard to a custom PCB turns that lesson into a physical object: the microphone, controller, button, connector, and level shifter all gain fixed locations. By the New Year's party that welcomed 2026, the first version had moved well beyond a test pattern. It had become a small instrument, translating the air in a room into color.

That is the satisfying loop in this project. A pattern observed in a sunflower becomes coordinates, coordinates become printed cells, cells become electronics, and electronics turn sound back into motion.

ahsan

ahsan

Hello! I am Mr Ahsan, the writer of the Website. I am from Netherland. I like to write about technology and the news around it.

Comments (0)

No comments yet. Be the first to respond!

Leave a Comment

Your comment will be visible after review.