A colorful globe with the WS2801 LED strip

A colorful globe with the WS2801 LED strip

Looking for something nice that could be done with the WS2801 strips i bought, I came up with this idea to build a light globe. The arduino drives the strips and has a couple of programs it runs.

The best way to show how this all looks is probably some movies. (Beware, i used my cheap digicam to record, no high quality...). Some still pictures at the bottom.

The globe in action

Controlling the animation speed

Besides the challenge of physically building something that looks decent, writing the code was quite a challenge. I got reminded of the olden days so old I didn't even experience them properly. How to write code that fits into the ridicoulously small 2 kilobyte memory of the arduino?
I usually code PHP, where you don't care much about variable types, and memory is only relevant if you do really cricital things.

This globe is built from 10 0.5 meter strip pieces. With 32 leds per meter, thats 160 pixels. The array to give to the fastspi library alone eats away 3 byte per pixel. Then I implemented a particle system to control the effects. At some point, just nothing happened and after a while i figured that it was because the arduino ran out of memory. So i went to reduce the memory as much as possible. First i looked at the particles, because there are many instances of them. Changing int to byte saves one byte. I had like 5 values in 50 particles, saving me 250 bytes or more than 10% of my total memory.
Floats are even worse, because they eat 4 bytes. Finally, i managed to reuse the particle instances for the different effects that mainly differ by color, rather than instantiating two arrays of particles.

Another surprise was that the Arduino does not want you to use new. Instead of instantiating objects on the fly, my code now has a list of the objects it needs at startup and then does not allocate or deallocate any memory - which is certainly helpful to keep the program running without crash. Modern operating systems prevent fragmentation, but i guess the Arduino will not be able to do that, so after lots of allocate and deallocate even if you manage to not have memory leaks, you still could have fragmentation.

If you want to see how I do this, or reuse something, i made the code available at github.

Full view in green
Close-up of the globe
Before the refactoring (it just had to work...)


WS2801 Strip

Hi David, the globe is really nice. We are factory in China,
making WS2801 strips, also other addressable products,
such as WS2801 led modules, LPD8806 led strips and so on.
Pls click: www.gree-leds.com to know more about our products.

msn: britney.greeled@hotmail.com


yes, i think i even ordered from you. quality was ok, but unfortunately i had to put your company on my spam list because you completely ignored my request to not send any more advertising emails.

Comment On:

Not many blogs that contain such consistently readable and interesting content as is on offer on this one, you have earned the tiny amount of time it has taken to express my admiration at your endeavours. Many thanks.

Prototype help needed.

Great projects! I am a total newbie but trying to prototype an effect of a cluster of 4 leds traveling down the lenght of the WS2801(5 meter) in one direction. What is the easiest way for me to do this? I purchased from bestlightingbuy.com and received a led controller with LED007 edit software. But could not get it to work. Will a newbie like myself realistically be able to do this with the Arduino? I have a very short time frame. Any help or advise you can give me is greatly appreciated! Sorry for asking such a open ended question.


is it easy? it depends...

hi, well i don't know why their controller does not work. it might also mean that the strip you got is broken. running the strip with arduino is pretty simple - if you have some programmer skills. if not, i would not expect fast results - and honestly it might be more wise to learn programming something that runs on a computer with real debugging and such, and in a more beginner friendly language than C++.

  • remember to directly connect the 5V and ground wires directly to your power source. if you light all leds, 5 meters of strip will consume more power than arduino likes
  • i wrote some notes about how to connect the arduino in a previous blog post
  • if you need some inspiration for coding, take a look at my code at github. it should get you started even if you never coded for arduino before

hope this helps