Flame flicker simulation with RGB LED [SOLVED]

This is an idea I'm kicking around in my head. :slight_smile: I have a really nice, BRIGHT RGB LED module that I would LOVE to use to simulate the somewhat random color/brightness changes of a fireplace flame. Obviously, it would stay in the "yellow/orange" part of the spectrum, with the intensity of all 3 colors varying. (Very little blue, obviously, to keep it in the yellow color spectrum, but not ZERO blue.)

I know about the PWM outputs, etc... I was wondering if there was already some code out there that I could adapt. (So I won't have to reinvent the wheel!)

The closest I found while searching, was a guy who used PWM to control the brightness of 4 yellow LEDS in a random "sequence" to simulate the flicker and motion of a candle flame. (Back in 2008.) From his video, I would say he pulled it off. :slight_smile: He didn't post his code, tho. :frowning:

Mine won't simulate motion as I only have one RGB module. (For now!) The idea of the color changing is very appealing, tho. :slight_smile:

UPDATE: Further down, someone pointed out an article where someone used 3 LED's, and after some "fuss", I got it working. :slight_smile:

There are several projects on Instructables that might be adapted. For example: http://www.instructables.com/id/Realistic-Fire-Effect-with-Arduino-and-LEDs/ It uses two yellows and a red but perhaps replacing one of yellows with blue and adjusting some parameters will give a good effect.

That looks like a good starting point... something to tinker with, which is what I enjoy! :slight_smile:

Thank you! :slight_smile:

Here's the code from the guy's article... which I have only copy/pasted. Updates to come...

// LED Fire Effect

int ledPin1 = 10;
int ledPin2 = 9;
int ledPin3 = 11;

void setup()
{
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
}

void loop() {
analogWrite(ledPin1, random(120)+135);
analogWrite(ledPin2, random(120)+135);
analogWrite(ledPin3, random(120)+135);
delay(random(100));
}

UPDATE: It didn't work before, but it works now. :slight_smile:

From other posts I'm thinking the "ld returned 5 exit status" means that you can no longer run Arduino on Windows XP.

It has been working perfectly with my other projects, so I don't think it's that. There must be something in the guy's code that's just not QUITE right.

It compiles fine for me under Arduino 1.6.8 on Mac OS X 10.11.5.

Some bizarre compile/link errors/crashes seem to be caused by out-of-date executables that the IDE saves outside the IDE installation directory. Perhaps that is what is causing your particular problem. In such cases it appears that the fix is to delete or rename the old "Arduino15" directory and re-install 1.6.x.

On Mac OS X:
/Users/(username)/Library/Arduino15

On Windows:
C:\Users(username)\AppData\Roaming\Arduino15

On Linux:
/home/(username)/.arduino15 (a.k.a. ~/.arduino15)

Wow ! I was going to post a similar thread but just found this one !

I want to make a flickering flame effect for the side of my PC, illuminating a sheet of Perspex from below with the flame design engraved into it. Oughta be cool, just not sure how thin of Perspex I can get away with.

1 Like

I'm surprised that there have been so few replies to this. Oh well. I guess I'll have to "strike out" on my own. :wink:

Willie---:
I'm surprised that there have been so few replies to this. Oh well. I guess I'll have to "strike out" on my own. :wink:

What sort of reply were you expecting? You said "There must be something in the guy's code that's just not QUITE right." because you don't believe that the latest Arduino IDE won't work reliably on Windows XP. I don't see anything wrong in the code and it is VERY simple. You have not reported finding anything questionable in the code. We can't make you change OS or use an older version of the IDE to see if Windows XP is your problem. What more is there to do?

I'm sorry, John... this has been a low priority project, so I haven't been checking in as often as I should.

Today, the code compiled just fine. What changed? I honestly don't know... but it is up and running on my NANO just fine. (The LED's are flickering, and I can tweak the parameters, so I'm off to a good start.)

I guess we can chalk it up to "Windows being Windows". :wink:

Thanks again. :slight_smile: