How to place WS2812B RGB LEDs in a spiral pattern

The PCB Editor supports python scripting, so write a script to either directly calculate LED positions, or load the positions from some pre-calculated array.

Yours is certainly the prettiest post I have ever seen on the KiCad forum. That pattern on the upper left looks like the bidirectional spiral one sees in the seeds in the middle of a sunflower. Maybe that is why it is called a sunflower array. duh.

For some time I have been pondering how best to convert our torchiere lamps from quartz halogen to LED. One YouTuber connected an LED disk lamp but it was just tossed into the top reflector and they called it good enough without any mounting. Of course, for doing this I don’t think that a spiral arrangement is a lot better than a rectangular grid or anything else which spreads out the LEDs and their light and heat.

One thing…a personally designed (FR4 or aluminum) pcb with a bunch of LEDs on it would probably have exposed voltage on it; sort of a bad/dangerous way to go if connecting directly to the AC mains. But it does not need so many watts and I have a bunch of surplus laptop power supply adapters, so powering it from an 18V DC laptop power adapter instead of directly from the AC mains would probably be good. Add some sort of adjustable dimmer for dimwits such as myself.

Idk how difficult the python way is. I haven’t used it myself nor am I really good in pythonese.

Anyways what I can think of is to turn an image into a footprint using the user draw layer. Place the image/footprint in the PCB, put the grid on 0.1mm and drag all leds to marked positions. It is an easy method but it is also a lot of labour. With Ctrl Shift M you can manually rotate components to any number of degrees, if needed.

Depending on the LED count, it may be faster to learn the pyhton way from scratch though :joy:

Regards and good luck with you project :coffee:


Don’t forget to dump the screenshots here of the 3D previews when finished :+1:t2:

That may be helpful:

Thanks for the help! Before that, I had already written the graphics code to use Python, and the next step was to integrate with KiCAD’s API to implement footprint placement。

@BobZ @bask185 @paulvdh @greg_m

1 Like

I neither realized this was a bidirectional spiral, nor sunflower seeds formed this pattern, nor this pattern was called a sunflower array.

Simply AMAZING!!! what I learn on the Kicad forum :smiley:

1 Like

Have a look at this repo (placing footprints in circle). It may give you an idea how to use it for your pattern: