APA106 leds

For the RGB leds, I choose some cheap 5mm WS2812 clones. I bought 50 of them for 12€ on chineese shop. They are not as good as the original ones (NeoPixels for example), but much more cheaper.

Don’t do like me, buy opaque LEDs, the render will be better. (in fact, I’ve ordered opaque LEDs, but received transparent ones)

use

They are easy to use. They are composed of 4 pins: APA106 pins

  1. Data In: data that arrives from previous LED
  2. Vcc: +5V
  3. Gnd: Ground
  4. Data Out: data to send to the next LED

They receive data from Data In pin (at 400 or 800KHz), and propagate the next data arriving to Data Out pin. So to use several of them, we just need to chain them (each LED Data Out is linked to the Data In pin of the next LED in the chain).

The data sent is 3 octets, corresponding to the Red, Green and Blue values.

WARNING: for most of my LEDs( not all!), the Red and Green data are swaped. So I had to adjust manually this in my code (see RGB.py code).

library

For the moment, we are using the Light WS2812 library for AVR. This library proposes small code to communicate with WS2812 LEDs (it works perfectly with our APA106) using bit-banging.

NOTE: I’ve first chosen to use the USI Data Out of the AVR to drive the LEDs, so that I can use USI hardware instead of just bit-banging (better to use hardware peripheric when they are available instead of using software to emulate them). But it requires more of my time than just includes the Light WS2812 library and uses it directly (this library works out of the box, just need to indicate the pin configuration). But I probably cannot do it anymore with the final choice of the AVR (ATTiny88)

Blinkning

To make the LED blink, a 4-bit cycle (blinking cycle) is used, every 1/4 of second. It means any 4-second pattern (with 0.125s as quantization step) can be produced, like “2 seconds ON - 2 seconds OFF”, or “blink every 1/4 seconds”, or even “OFF-ON-ON-ON-OFF-OFF-ON-ON-OFF-OFF-OFF-ON”, etc. 16-bit word is used to encode the blinking scheme (bit at position i used to indicate if the LED is on at cycle i). During the communication between RPi and AVR, 5 bytes are used to define the color:

Color list

I have used the color list make by Sasha Trubetskoy, slightly corrected (the Python list is in RGB.py).