2.1.35. Exercise: WS2801 RGB LED SPI Module

2.1.35.1. Objective

Communicate digital data between an Arduino and a WS2801 LED RGB module using an SPI bus.

Please be sure to review the general information about I2C and SPI in Exercise: Adafruit PWM I2C Module prior to starting this one.

This exercise will use a RGB LED strip module based on the WS2801 constant current LED driver, also available in a variety of other form factors.

These modules accept a 24-bit color value over an SPI bus, then begin to relay any additional bits to the downstream SPI connection. This allows daisy-chaining many RGB LEDs into an individually addressable array of pixels. Once a short pause occurs in the input data, the received values are transferred to the internal PWM generator. This allows simultanous update of the whole chain for clean animation.

2.1.35.2. Steps and observations

  1. Download or find the complete WS2801LED sketch.

  2. Plug the RGB module into a breadboard and use solid wire to make the following three connections from the Arduino to the module. Note carefully that this module uses 12V; be very careful to keep the 12V wiring away from the Arduino:

    1. PIN11 (MOSI) -> DAT
    2. PIN13 (SCK) -> CLK
    3. GND -> GND

    MOSI is an acronym for Master-Out Slave-In. Since this example only outputs data and does not receive, MISO is left unconnected.

  3. Set up a bench supply for 12V and attach it to the Arduino GND and the 12V input on the module.

  4. Attach the Arduino to your computer and install the sketch.

  5. Observe the changing colors.

  6. Using an oscilloscope, observe the clock and data lines. The data rate is fast, so you should see one very short burst per output frame.

2.1.35.3. Comments

It is possible to control hundreds of LEDs on a single strand. This is becoming a very popular way to produce architectural lighting and persistence-of-vision (POV) displays.

2.1.35.4. Arduino Code

  1. Documentation: WS2801LED Arduino Sketch
  2. Sketch Folder: WS2801LED