RGB LED Ring V2 + ShiftPWM — super smooth color fading

The supplied demo code uses a variant of binary code modulation / bit angle modulation (MIBAM). That is perfectly fine and very cpu efficient for keeping a certain brightness level. Smooth fading however does not (yet) work completely satisfactorily.

You need at least a 2.0beta board for this to work!

Therefore I have investigated if ‘ShiftPWM (1.03)‘ can be used – which uses true PWM and gives super-smooth fading!

And it works! (with a few tiny modifications to the code – no worries).

Install (unzip) the library to the libraries folder of the Arduino IDE (0023 tested).

The rest of the procedure is described in the ‘readme.txt’ of the demo code repository:

— — — readme.txt — — —

If you need super-smooth color fading, please use the Arduino ‘ShiftPWM’ library.
It works with the Arduino IDE V0023 (tested).

Download location: http://code.google.com/p/shiftpwm/downloads/list

There are a few short modifications to make it work:

1.) Open the file ‘CShiftPWM.cpp’ in the library folder.

2.) Search for the function ‘CShiftPWM::SetGroupOf3’ and replace it with this:

This takes care of the different arrangement of LED drivers. The original library assumes:
RGBRGBRGB… and so on. The LED ring board uses RRRRRRRR – GGGGGGGG – BBBBBBBB.

If you need the other functions as well, modify them accordingly.

Don’t forget to save the file before you compile code.

3.) Insert these 2 lines in the setup() function of the ‘ShiftPWM_Example1’ example.

This enables the LED drivers on the V2.x.x ring boards.

4.) change / set these variables in the ‘ShiftPWM_Example1’ example:

5.) Compile and upload.

Have fun!

— — — readme.txt — — —

Here’s a short video as proof that it does really work. The flickering is a camera artifact.

This entry was posted in Arduino., Electronics. and tagged , , , , . Bookmark the permalink.

2 Responses to RGB LED Ring V2 + ShiftPWM — super smooth color fading

  1. Polhemic says:

    In previous posts, you revealed your “reduced CPU usage PWM timer” magic for doing software PWM. Are you going to try the same tricks on this board or does the shiftPWM library already use this approach?

  2. robert says:

    The demo code I provide for this board uses this ‘trick’, if you want to call it that. Unfortunately there is one big disadvantage, which is described in this excellent post on a pic-centered forum. It is perfectly fine for keeping a certain brightness level, but it fails at smooth transitions.

    That’s why I chose to also use ShiftPWM. The cpu load is higher, but as the main purpose of this toy is to provide nice colors and smooth transitions and it doesn’t do much else, that path is acceptable.

Comments are closed.