Individually addressable multicolour LED’s on .NET Gadgeteer

[UPDATE]: Sarah and Jan emailed me to mention that the 10A@5v power supply is a bit of an overkill. I agree but this is the recommendation from GHI. When I tested my strip on full power it was under 3A@5v . Jan claims his is around 2.6A@5v . This does not account for peak current draw, so you may hit issues, but perhaps the full 10A is a bit much.

Who does not like LED’s? They are fun and amazing, especially if you by a 5m strip of individually addressable multicolour LED’s. I had a whole pile of important work to get done today but for some reason the FEZtive kit I ordered ages ago was just begging to be used. More importantly I found a power supply that will give 10A@5v so I had to have a play.

The first hurdle was finding out how to power the module 160×3 LEDs (RGB) is a lot to power and GHI recommend a good power supply which is attached to the FEZtive module board part A, this way you are not drawing power through the .NET Gadgeteer mainboard. In the picture below you can see my power connector. (Not I have not split the PCB as I only need one connector for now and this way I don’t loose the other half.)


Next I need to connect the connect the LED strip to the PCB, my strip had a connector on each end and as I planed to run this as a single strip, I cut the connector off the end and attached it to the PCB. This way I can disconnect the LED strip. Now I have power, data (Gadgeteer cable) and a connector for the lights.


Connect it all up and we are ready for some software….


There is a great example of how the use the module here : 

At the time of writing the FEZtive module is not part of the main GHI installer (I guess it will be in time) so you need to download the project from the link above. Be sure to add this project to your solution (or new project),


Next add a reference from your project to the FEZtive project you just downloaded. (I am using NetMF 4.2 so add a reference to the _42 project.)


Since you cannot drag and drop the module from the designer (not yet) you need to create the object on the socket that you are using, I have a Spider with SPI on socket 9. Here is the example code from: 

  1. public partial class Program
  2. {
  3.     // This method is run when the mainboard is powered up or reset.
  5.     FEZtive feztive;
  6.     void ProgramStarted()
  7.     {
  8.         Debug.Print("Program Started");
  9.         feztive = new GTM.GHIElectronics.FEZtive(9);
  10.         // Initialize the module to use 80 LEDs, with an SPI clock rate of 4Mhz
  11.         feztive.Initialize(160, 4000);
  12.         // Set every LED to Black (off)
  13.         feztive.SetAll(feztive.Black);
  14.         // Set every LED to Red
  15.         feztive.SetAll(feztive.Red);
  16.         // Set every LED to Red
  17.         feztive.SetAll(feztive.Red);
  18.         // Set every LED to Green
  19.         feztive.SetAll(feztive.Green);

Fantastic this works! (It is hard to take a picture, they look better in real life)



The FEZtive part B

The LED’s are connected by 4 lines (Gnd, CI, DI, +5v) and you don’t need anything on the ‘end’ of the LED strip, as it is just one big long SPI bus. So in theory you can cut the strip (there are marked points to cut after each LED- see the white line) into different sizes. The PCB that my kit came with has 2 parts and A and a B, each with 5 areas to connect an LED strip. Think of these PCBs as U-turns in the LED strip. You can cut it into 5 x 1m strips and then zigzag them between part A and part B, note that this will make the order of the LEDs into a long snake, so if you are writing text or showing a picture you will need to calculate which LED is where. (Yes you can link multiple together – I only have one)


How does it work?

If you look at the GHI driver for this module you can see that there is a large array (one for each LED) which contains a custom ‘colour’ object. There are a series of public methods that let you manipulate this array (change the colour) and then there is a draw method that will ‘write’ the entire array of ‘colour’ objects to the SPI bus.

There are some interesting effects of this. Imaging you have a LONG strip, say 5m and decide to set the colour to blue, you can see the new colour advancing along the strip. It is easier to see if you slow the clock speed down.

  1. feztive = new GTM.GHIElectronics.FEZtive(9);
  2. feztive.Initialize(160, 500);

This got me thinking, how is it working? Imagine you built a new (very large) HD TV out of this would it work? Well not exactly, you would get rather ugly ‘scan’ lines and the refresh would be poor.

Change the colour

I have a .NET Gadgeteer colour sensor and setup a button that would read the sensor and set all LEDs to that colour. Handy to test and a little more fun as you can point it at an object, press a button and all the LEDs change colour.

Here is a bit of code:

  1. void button_ButtonPressed(Button sender, Button.ButtonState state)
  2. {
  3.    // colorSense.ToggleOnboardLED(true);
  4.    ColorSense.ColorChannels cChan = colorSense.ReadColorChannels();            
  5.    GTM.GHIElectronics.Color newColour = new GTM.GHIElectronics.Color((byte)(cChan.Red / 2), (byte)(cChan.Green / 2), (byte)(cChan.Blue / 2));
  6.    //  colorSense.ToggleOnboardLED(false);
  7.    feztive.SetAll(newColour);
  8. }

Something is a bit strange here, the colour sensor returns a uint for each of RGB as well as an intensity. The FEZtive LED strip takes a value between 0-127 for each of the RGB. For now I halved the channels, but this is not correct and for extreme lighting conditions it will produce strange results. I plan to normalise these values, but so I can test a bit more this will do for now. I could not find a datasheet for the Colour sensor module and the source code does not give away much. humph! – GHI? The driver reads 2 bytes fore each channel 2^16 colour options per channel, but I noticed that with a bright light the values rarely top 10,000. (e.g RED: 9715, GREEN: 12368, BLUE: 11918) [UPDATE :]

  1. public ColorChannels ReadColorChannels()
  2. {
  3.     ColorChannels returnData;
  5.     byte[] TransmitBuffer = new byte[1];
  7.     TransmitBuffer[0] = 0x90; // Send COMMAND to access Green Color Channel register for chip
  8.     returnData.Green = readWord(0x90, TransmitBuffer)[0];
  9.     TransmitBuffer[0] = 0x91;
  10.     returnData.Green |= (uint)readWord(0x91, TransmitBuffer)[0] << 8;

The LDP8806


Each multicolour led on the strip has a processor next to it, yes every one! This is the LDP8806 – anyone got a data sheet?

Something is interesting here, you just tell the Gadgeteer initialiser how many LEDs there are, and then ram data down the SPI bus. If you say there are only 10 LEDs then only the first 10 in your strip will work. This means that the data is fed to the first led in the strip, the colour is set and then all subsequent data is passed down the SPI bus, to the next LED and so on. 

There is a series of zeros that are passed into SPI before and after each call, and this depends on the length of the strip. (presumably to set the LED into a state where it can obtain a new colour). I think this explains why each value is limited to a range of 0-127, the high bit is being used to command each LED.

  1. _zeros = new byte[3 * ((numLEDS + 63) / 64)];

Ok, enough speculation, here is a much better explanation:

Can it go faster?

For a bit of fun I decided to see what SPI clock rates would work with my 5m strip.

  1. FEZtive feztive;
  2. void ProgramStarted()
  3. {
  4.     Debug.Print("Program Started");
  5.     feztive = new GTM.GHIElectronics.FEZtive(9);
  6.     feztive.Initialize(160, 500);//OK
  7.     feztive.Initialize(160, 1000);//OK
  8.     feztive.Initialize(160, 2000);//OK
  9.     feztive.Initialize(160, 4000);//OK
  10.     feztive.Initialize(160, 8000);//OK
  11.     feztive.Initialize(160, 16000);//Some LEDS are the wrong colour
  12.     feztive.Initialize(160, 12000);//OK
  13.     feztive.Initialize(160, 14000);//OK
  14.     feztive.Initialize(160, 15000);//Some LEDS are the wrong colour
  15.     feztive.Initialize(160, 14500);//Some LEDS are the wrong colour
  16.     feztive.Initialize(160, 14000);//OK

So it would look like 14MHz is as fast as this will run without errors. It is not exactly scientific, so the plan is to run at at this speed for a bit and see how it copes.

2 thoughts on “Individually addressable multicolour LED’s on .NET Gadgeteer

  1. Pingback: Colour sensor on .NET Gadgeteer (TCS3414) | Steven Johnston

  2. Pingback: Colour sensor + LED strip video | Steven Johnston

Leave a Reply

Your email address will not be published. Required fields are marked *