Controlling WS2812 LEDs - How to do faster?


OK - it might be worth giving one more try @back_ache. Someone noticed a couple issues with code last night which we resolved this morning.

You’ll need to change this line(102):

const NUMPIXELS = 64;

to be the number of pixels on your board/ring. If the code works, you should have a moving red pixel.


I have got it too come to life, I connected it to the aprils “data ground” rather than its “battery ground” I was using.

It is now going though a pattern of red lights.

Thanks for all your help, next step is to try the original strip with the data ground.


Awesome :slight_smile: Glad we could get it working!


Sorry I could not write earlier. I am not sure if that was clear from the previous post, but after I found the correct code it all started working. Again thx a lot!


The constant current chip is the WS2811. The chip itself has two speeds, 400KHz or 800KHz. the WS2812 runs at 400KHz and the WS2812B runs at 800KHz.
Communication to these devices is via a daisy chain with a NRZ type wave form. Each chip has 3 channels with 8 bit PWM.
So, at 800KHz to send a 1 bit you send a high pulse of duration 0.8uS and the a low of 0.45uS.
To send a 0 bit you send a high pulse of durations 0.4uS and then a low of 0.85uS.
Total bit lenght is 1.25uS ±300nS
The timing tolerances are ±150nS


Can the code work for this easy diy ws2812b matrix? they are designed in vertical circuit.


As I am extremely new to the Imp (my first one arrived on Friday), I will be using the imp to control my arduino mini, which is running the absolutely stunning FastLED animation library.

At about $3 for the mini, and with a wealth of code already in my library, it’s a no brainer until the FastLED boys port their library to the Imp (or the Spark…).


Hi! FastLED developer/maintainer here - I’m currently going on a tear getting FastLED ported to a variety of new platforms, and someone recommended the Electric Imp to me as a possible platform. Unfortunately, all the docs that I’ve found so far simply have a generic reference of “cortex-M3” as the arm core in the chip. In order to port FastLED I need to actually know what the actual chip is, and the reason for this is that every arm manufacturer (Freescale, Atmel, STM, Nordic, NXP, etc…) does their low level device access (GPIO, SPI hardware, etc…) wildly differently.

If that information is obtainable, I can look into seeing about doing a port.


Ah, nice looks like it is an STM32F205RG - which is the same family as the Spark Core, which I’m mostly finished with the FastLED port. The next big issue is going to be integrating it with the online IDE that electric imp uses. That was a bit of a pain in the ass with the spark environment, somehow I suspect that the imp isn’t going to be much better.

Does the electric imp allow for any form of local development/upload of code, or am I forced to go through a network cycle every time I want to flash?


There’s no low level assembler access on the imp - sorry. User code only runs within the VM, so no fastLED port is possible I’m afraid.


will be the same for the ws2813b leds,
for I have seen many controller can support them at the same code,