Share My Creation JG LEDStrip APA102


Here is a small App that I wrote to control APA102 LedStrip.
APA102 are RGB leds that can be individually controlled via a SPI bus.
They are linked in a daisy chain so that a single SPI Master bus can address the whole strip.

A PIC24FJGB106 board takes care of sending the SPI data over the bus.
The Android App is simply reading a picture, converting it into RGB data and send them to the MCU over bluetooth or Wifi
The link between the Bluetooth or Wifi modules and the MCU is UART.

Apk is not yet published on the GooglePlay and too big to be uploaded...
BTW it needs my MCU board to work...

You can :
  • connect over wifi or bluetooth
  • choose the image
  • change the speed
  • change the brightness

Here is the result :

As you can see it works quite well, but the speed is not as fast I would have expected...
This is due to the UART protocol which is quite slow (115200 bauds max)
I can achieve much faster throughput via the SPI bus but the limitation is really the UART.

An idea would be to get a Wifi to SPI board and send raw data directly to the LedStrip without MCU board.

I have in mind the very cheap ESP8266 board with custom firmware. But I don't know yet how to change firmware !

Any other idea would be appreciated

[Edit october 2015] Here is a new version running with an ESP8266 (cheap) board.
This board is loaded with ESP8266 Arduino firmware. With it I could easily access to the hardware SPI bus.
The result is a much faster system.
Connecton is fully automatic, no parameter to enter. Simply UDP broadcast and then UDP connection between Android and ESP8266.



  • LedStrip APA102.jpg
    LedStrip APA102.jpg
    32.5 KB · Views: 11,607
  • LedStrip.jpg
    19.1 KB · Views: 413
Last edited:


Well-Known Member
Licensed User
Longtime User
Very interesting, I can sense a new project coming on :D

Here are some pictures of my son's Captain Bed which I built myself, now my daughter wants lights in her room!







Well-Known Member
Licensed User
Longtime User
Very nice realization ;)

How many leds do you have in this room ?

My LedStrip is 4m long with 240 Leds. They sell up to 144 leds/m (rather expensive)
Mine is (only :)) 60 leds/m

The more leds the slower the animation effect and bigger the price.

As it is a single SPI bus you can cut the strip and connect the bits with wires. Beware however that the SPI signal may decrease if these wires are too long.
BTW there is no problem of attenuation between two leds as the internal chip takes care of SPI signal regeneration.

I have choosen to pilot the ledstrip with a simple jpeg image, the "pattern editor" is simply photoshop. You can "paint" the ledstrip pattern and get almost whatever you imagine.
With vertical stripes you could have a color per step on your staircase ! And with a diagonal line a nice "climbing light"

The code is highly optimized to prefetch the image into memory in order to avoid lag between "lines".
With a HLK-RM04 wifi to serial board, I can sustain a refresh rate of 32ms (with 240 leds individually addressed)
The limitation is the serial port ... currently 230400 bauds !

The software can (not tested) handle any number of leds with a refresh rate almost directly proportionnal to the number of leds.


Well-Known Member
Licensed User
Longtime User
@freedom2000 here's the link to the LED's I used...®-Waterproof-Flexible-Remote-System/dp/B008H40EGG/ref=sr_1_21?ie=UTF8&qid=1424539880&sr=8-21&keywords=rgb led strip 5m
I've used all 300, they're the ones you can see edging each step and across the front of the bed. Plus I've placed a small strip inside the cupboard so that there's some light in there. But these are only basic LED's and very cheap. For £16 you get 5 metres of LED's (300 5050 SMD RGB LED's) and the LED driver with a 44 key remote control. A decent power supply can be had for under £10 and so it's a nice and cheap solution. At full power there's a lot of light emitted! My son loves his room.

Now my 13 year old daughter wants lights in her room!
Last edited:


Well-Known Member
Licensed User
Longtime User
I think I'm going to have to experiment with my Raspberry Pi and see what's possible. I've been wanting to put it to some good use!


Well-Known Member
Licensed User
Longtime User
That can easily be sorted with an opto-isolator or two ;)


Well-Known Member
Licensed User
Longtime User
Nice job @RandomCoder,
I actually thought that you were in the USA until I checked your details.
Hmm, back in the day I used to go clubbing at 'The Pink Coconut'e in Derby :)
Hmm back in the day, hey! I'm still pretty young at heart thanks to having three kids but it seems an awful long time ago when I last went out clubbing :eek:
I look back and think to myself how did I ever manage to afford it! ;)


Licensed User
Longtime User
Wow!! Great job!!

How many bytes did you get to transmit at once with the HSPI of the module? I found somewhere that the buffer is 64 but haven't gone deep into it

Also, which is the max SPI speed?

Would like to do something similar with video onto square panels


Well-Known Member
Licensed User
Longtime User

I receive the full frame via UDP (without headers and trailers) and I transmit it byte per byte to the SPI bus.
Its max clock frequency is 1MHz.

For video I am not sure that the speed will be enough...


Licensed User
Longtime User
Hi JP!

Thanks to you and other members who have published posts about it, I have also started my project with the ESP

It consists in a 16*16 APA102 square panel controlled through SPI by an ESP-07 (very similar to ESP-12) using Arduino for ESP8266 (in fact at this moment is only 16*10, pending to connect the rest)

I made a small B4A drawing app in which you can draw directly the pixels and change its color and global brightness. Each time you make a change, it is sent using UDP to the ESP-07. It works fine!



About the HSPI speed:
It "seems" that it can be programmed to run much faster, at even 40MHz (if the hardware you are addressing allows that ) NOT TESTED
Also, you can transmit some buffers (very limited in size) NOT TESTED. So, you can split the big buffer into multiple chunks and send one when the previous has just been sent.
The drawback is that, at least with the arduino IDE, (perhaps I am wrong) there are not SPI interrupts, This would be ideal for the above point. Anyway, it can still be done by polling the SPI state in the main loop.
So, next step will be to measure the max real SPI speed that can be achieved.

RGBLed considerations (if someone wants to do imaging)

I made the "prototype" panel cutting 16 pieces, each one with 16-led, from a 5m 60led/meter APA102C. Then I put these pieces one under the other, so that the result is a square 16*16 panel.
The scan is from left to right for the odd rows and from right to left for the even ones because this is the way the rows are connected between them. So, the B4A app makes this pre-processing before sending the frame to the ESP-07
Color: The LED colours are far from "neat". Red is near orange, and less bright than the others. So, a little processing has to be done with the image to improve it
Pitch: with a 60leds/m strip, the distance between leds is 1,67cm. I have seen some panels with 10mm pitch, which, given the led size, seems better for images. But also, a higher density means higher cost.

Hope to be able to post a video when it is finished!