Input to LEDs

Hi all,
I’m new here and I’m sorry if this topic has already been covered but I couldnt find anything in the search function.
I’m not a programmer so please be gentle… :slight_smile:

I’m looking at using arduino to control my project which is to re-create Shakespearean candle light using LEDs. I work in a theatre which uses a DMX cable to control lighting which is 8 bit and goes from 0-255. However, this is not enough as I need to colour mix red green and blue and if I add one more unit of, say green, the colour then becomes too green so i need smaller steps - hopefully 10 bits per colour. It doesn’t really matter what method I use to control the LEDs (i.e. USB etc) as I will be making these up to fit inside a chandelier I made earlier this year. So, I can adapt my design around the software if necessary.
I want to know if the Arduino PWM control is capable of this? I can’t seem to find the answer anywhere online.

Thanks in advance.

Look at Candle LED with Simulated Flicker, Fighting with computers, BlinkM-Smart LED.

Juan C.

I’d be inclined to go with the BlinkM, although I’m not certain just what it would take to get the flicker right. The technique I’ve seen for doing the flicker involves using a cap to smooth things out.

You can also “roll your own” PWM for higher intensity resolution and use digital pins. The tricky bit is working in new values for R,G,B over the wire. Here’s an example, but if you go much over 2048 in the loop count you will probably start getting flicker:

#define rpin 2
#define gpin 3
#define bpin 4

void setup(){

//make up some rgb values, range is 0 to 2047
  unsigned volatile int r=30;
  unsigned volatile int g=1024;
  unsigned volatile int b=899;

void loop(){
  for(int x = 0; x<2048; x++){

Thanks everyone for your comments. I will be looking at the flicker side of candle-light but that will come later in the project. For now, I want to get the mix of colours right and that involves getting the smallest possible output values so I can do the tiniest tweeking of colour.
Excuse my ignorance, but what do you mean by if I go over 2048 in loop count I will get flicker? Thanks

I think he means that you can increase the PWM resolution as much as you want by increasing the period (2048 in the example), but at some point the period gets so long that the eye doesn’t perceive it as dimming/brightening, but flickering. If you had a 50% duty cycle but the period was a second long, your eye would of course see that as a blink and not as a 50% dimming.


Ahh, ok, now I get it. Thanks! Up to now, I’ve only had 0-255 so maybe that would be enough… Might give it a go! Thanks everyone!

And if you wanted 10 bits of accuracy, you could just use 2^10=1024

I make and sell ShiftBrite modules, which can do 10 bits per channel. You can also tweak the separate 7 bit current control registers for fine adjustment.

But this would only be ideal if you needed control over a number of individual lights. If you’re controlling all the LEDs at the same time, you might want to find a PWM signal generator circuit that you can control with a potentiometer, for very fine control of the color of each channel. You could use the PWM signal to control a MOSFET and power all of the LEDs at the same time.

There is a schematic in the datasheet for the 555 that demonstrates it’s use for PWM. I was wondering about the idea of using a 555 doing PWM, feeding into an NE602 mixer, with a suitably random input for the LO port. Maybe a noise generator circuit, but you’d want it running at a low enough frequency to produce a suitable flicker. The whole output could then go through a low-pass filter to smooth things out.

Each ‘candle’ does not have to be controlled individually. I have 2 chandeliers with 8 candles on each, so I thought each chandelier would have its own unit to get the colour to. The only thing that would be different would be the flicker. If all 8 flicker at the same time, it will look silly. but, like I say, I’m not too worried about that at the mo - I’d like to get the colour right first.
So, if I found a unit with a potentiometer, would this still go through Arduino or would it be something seperate?