Arduino and WS2801 RGB LED strip

Arduino and WS2801 RGB LED strip

Recently, i ordered a sample of a ws2801 based RGB LED strip from China. After todays successful playing around with it, I plan to order a bigger quantity beginning of next week.

RGB strips contain a number of individually addressable RGB LEDs - in this instance 32 per meter. Each RGB pixel has its own tiny controller to control its color. The color is quite bright, green and red almost hurt my eyes at the maximum brightness. White has some blueish-violet quality, which makes it look interesting but its not perfect white (i read for that you would want LEDs with an additional 4th white LED which my strips seem not to have). The WS2801 protocol sounds simple, but instead of implementing it, i just took the library fastspi for the arduino SPI component. The code for the loop() function to produce "walking" red, green and blue dots looks like the following (plus some initialization as found in the sample of fastspi):

// walking r-g-b
for (int j = 0; j < 3; j++) {
    memset(leds, 0, NUM_LEDS * 3);
    for(int i = 0; i < NUM_LEDS; i++ ) {
        switch((i+j) % 3) { 
        case 0: leds[i].r = 200; break;
        case 1: leds[i].g = 200; break;
        case 2: leds[i].b = 200; break;
    }
}
FastSPI_LED.show();
delay(300);

The hard part was figuring out which cable fits into which pin of my Seeeduino (Arduino clone). There is something printed on the strip, but the names do not all match the documentation. And the manufacturer of the strips got the coloring scheme of the cables rather weird, use a non-standard byte order for colors and the sample code did not work out of the box. Luckily i figured it out with reading some of the Arduino spec and have the info gathered here for reference (Warning: The cable colors seem to be random, not all of my strips have the same color for the same thing):

  • 5V = + 5 volts
  • CK = SPI clock, pin 13
  • SD = SPI data (master to slave, MOSI), pin 11
  • GND = Ground

Note that SPI knows two more pins, SS and MISO, to switch communication from slave devices to master and receive data from slaves, but the strips have no cable for that and its not needed as there is nothing to read from the strips.

The color order i had to use with fastspi was struct CRGB { unsigned char b; unsigned char g; unsigned char r; };. (You can easily try this out without any danger of breaking something, just set one field to 255 and the others to 0. Whatever that color is is in that field and can be named accordingly.

I had to manually set the SPI DataRate to 2, below 2 i get lots of weird flickering. fastspi claims to set the data rate based on the chipset but either my WS2801 are not original or otherwise flawed or something is wrong with the library. Whatever, you can do FastSPI_LED.setDataRate(2);. To figure out your value, start with rate of 7 (slowest) and lower down to 0 until you get flickers when adressing all LEDs.

Thats it for now, but stay tuned for more once i get longer strips of LEDs :-)

Comments

Red LEDs not working

Hi I ordered a 5m WS2801 12v SMD5050 led strip from a Chinese manufacturer. I've been using the Fast SPI library examples, as well as your own example, but for some reason I can't seem to get the green or blue leds to work. Only the red leds work. I'm not exactly sure whether or not it is the cable connections to my arduino uno or if it's broken/dead on arrival. I have the 12V wire connected to the 5V pin (I know it's not enough but I don't have a 12V adapter at the moment). CLK (clock) connected to pin 13, DAT (data) connected to pin 11, and GND connected to Ground pin.

I used this color order:
struct CRGB { unsigned char b; unsigned char r; unsigned char g; };

I've used other example code (not from the Fast SPI library) and could only get the red leds to light up.

Some of the wires are slightly bent but could that be the reason for the problem?
Any ideas on what could be wrong?

RE: Red LEDs not working

hi,
not sure but what jumps to my mind is that the lower voltage could be a problem. if your strip expects 12V i doubt if 5V can make it happy. the order of the CRGB struct is not important as long as you try out stuff (you don't care if the red value is green or blue...).
can you have different brightness of red? do you have just one strip or multiples? it can always be that there is something broken with your strip.
but connection problems with the cables would lead to no light at all. or when there is flacky connections or too fast clock, i get to see flickering colors. there is no separate wires for each color, but the data cable tells the chips what LEDs to light...
good luck.

Have you tested to see if 5v

Have you tested to see if 5v supply dropping too much under load? What kind of current are the 15 pixels drawing? And I plan to buy the same WS2801 RGB led strip from http://www.bestlightingbuy.com/ws2801-addressable-rgb-led-strip.html , how do you think of it?

WS2801 Addressable led strip

the WS2801 has a few technical shortcomings in comparison but is very available, common, supported, etc and will remove the guess-work for you if you’re working on something where that’s important. In brief comparison you’ll have to run a WS2801 at less than a quarter the refresh rate of a LPD8806 (2Mhz vs 8Mhz, plus a 500uS latch time on the WS2801) but it does full 24-bit color instead of the LPD8806′s 21-bit. I recently bought WS2801 from http://www.gree-leds.com/productshow.asp?ArticleID=PS7188S784 for only $65 per reel.

Power consumption

hi,

according to the manufacturer, 5 meters of this strip could draw up to 6 ampere (if you light all pixels maximum white). that depends more on the leds than the controller though, so just check the info from where you want to buy them. i have a power brick that delivers 3 ampere and a program that lets 5 meters of strip light - see my newer blog post. I also use a PC power brick - that delivers more than enough power to keep the 5 volts up with lots of leds.