Instructables

Realistic Flickering Flame Effect with Arduino and LED's

Picture of Realistic Flickering Flame Effect with Arduino and LED's
Picture 2.jpg
Picture 3.jpg
In this project we will use 3 LED's and an Arduino to create a realistic fire effect that could be used in a diorama, model railway or a fake fireplace in your home or put one inside a frosted glass jar or tube and no-one would know it wasn't a real candle inside.

This is a really simple project suited to beginners.
 
Remove these adsRemove these ads by Signing Up

Step 1: Step 1 - Wire up the LED's

Picture of Step 1 - Wire up the LED's
Wire up 3 LED's. Use 2 x Diffused Yellow and 1 x Diffused RED. You can increase the number of LED's if you wanted a larger or brighter display. Consider the use of transistors if your amperage will go over that which can be supplied by the Arduino.

Use resistors that suit your particular type of LED.

Step 2: Enter the Code

Picture of Enter the Code
Enter this code:

// 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));
}

Step 3: Upload and run

Picture of Upload and run
Upload the code to the Arduino and run it. You will now have a pretty realistic flame/fire effect from the LED's. Bounce the light off a white card or a mirror to achieve the full effect.

Step 4: Video of the effect

Picture of Video of the effect
Video of the effect. The colours and the effect don't show up very well in the video. In real life it is a very effective flame effect. Give it a try.


admin5 years ago
Hey, this is a great instructable and is very informative. Just one thing is missing... pictures! It really helps a lot when trying to follow directions so you should consider taking some photographs. Once you do that and leave me a message when you have so that we can publish your work. Thanks! Thanks for the cool instructable and we hope to publish this soon!
admin5 years ago
Hey, this is a great instructable and is very informative. Just one thing is missing... pictures! It really helps a lot when trying to follow directions so you should consider taking some photographs. Once you do that and leave me a message when you have so that we can publish your work. Thanks! Thanks for the cool instructable and we hope to publish this soon!
goldenshuttle4 months ago

Very simple; & very impressive..

rastita4 months ago

Hi! thanks you very much... i was coding something very complex and you gave us a very simple but efective candle efect ;)

Instead of a full Arduino, i used an ATTiny85, and added a swich...

Thanks a lot!

2014-04-05 00.30.41.jpg2014-04-05 00.30.09.jpg
Thanks for the great Instructable! Saved me a bunch of time writing the code myself!
SubEclipse1 year ago
Easy and looks great.
tinker2342 years ago
i wonder i saw a video where some one used a smoke maching thourgh tube with holes in it with a simallar led array with yellow to create a realstic fire
HSTH2 years ago
Great project - it works great - anyone with an Arduino ought to give it a try.
what would it thake to make a torch instead of a candle flame... im thinking on use them as lightning for a corrior in my house, ill like to draw electricity direclty from the wall
0_Nvd_05 years ago
Very COOL Earthshine. You have invented a very nice thing.
TheArduinoGuy (author)  0_Nvd_05 years ago
Thanks
bigdeee5 years ago
That's a great little effect that goes a long way! I'm sure it's going to come in handy in my little video experiments. Thanks for posting it.
TheArduinoGuy (author)  bigdeee5 years ago
Glad you like it. It's very effective in real life.
ReCreate5 years ago
Instead of using all those resistors...Couldn't you just use one from ground to the led's negative terminal? and put all of the positives directly to the board?
TheArduinoGuy (author)  ReCreate5 years ago
No because the LED's go ON/OFF so the current would then increase/decrease and could damage one or more of the LED's. If each one has it's own resistor then it will be individually protected.
what about for cases when only 1 LED is on at a time?
Rob K5 years ago
Random brightness neet little effect. Try that with a RGB LED.
Rob K Rob K5 years ago
Actually using RGB LEDs is a nice effect.
TheArduinoGuy (author)  Rob K5 years ago
The reason individual LED's are better, rather than an RGB LED, is that the seperate LED's cause the shadows to come from slightyl different points. This increases the realism as a flickering candle has a flame that dances about causing the shadows to shift slightly. If you use an RGB LED then all of the points of light come from the same location and the shadows remain stationary.
I meant red green and blue LEDs not just a singe RGB one sorry. I just got my starter kit working again and this is one of the first sketches I tried.
TheArduinoGuy (author)  Rob K5 years ago
Cool :)
koensadza5 years ago
Those Fritzing images are really nice!
I just noticed the two resistors on the right are not located right. As they are now, they are between + and ground.
TheArduinoGuy (author)  koensadza5 years ago
You were right! I've fixed it. Thanks.