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.

## Step 1: 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.
<p>Hi! thanks you very much... i was coding something very complex and you gave us a very simple but efective candle efect ;)</p><p>Instead of a full Arduino, i used an ATTiny85, and added a swich... </p><p>Thanks a lot!</p>
<p>Do you have a circuit diagram by any chance? </p>
<p>hi rastita. this is a very awesome project you created. im interested how you wired it. it. code uses two leds but i see four. lol unless the others are just there. i see you connected leds with resistors on pins 5 and 6. your battery case looks like it takes two 1.5V batteries. AA or AAA? truly and awesome project.</p>
Hey Rastita, can you provide the code? Superthanx!
<p>Yeah! for shure.... but it&acute;s almost the same than the original :)</p><p> But only using 2 leds, instead of 3...</p><p>// LED Fire Effect</p><p>int ledPin1 = 5;</p><p>int ledPin2 = 6;</p><p>//int ledPin3 = 11;</p><p>void setup()</p><p>{</p><p>pinMode(ledPin1, OUTPUT);</p><p>pinMode(ledPin2, OUTPUT);</p><p>//pinMode(ledPin3, OUTPUT);</p><p>}</p><p>void loop() {</p><p>analogWrite(ledPin1, random(80)+35);</p><p>analogWrite(ledPin2, random(120)+135);</p><p>//analogWrite(ledPin3, random(120)+135);</p><p>delay(random(100));</p><p>}</p>
<p>Actually there could be 3 random flickers + 2 random fading using PWM on pins 0 and 1 with bursts to simulate little flame with occasional crackers. :-)</p>
<p>Very simple; &amp; very impressive..</p>
Thanks for the great Instructable! Saved me a bunch of time writing the code myself!
Very COOL Earthshine. You have invented a very nice thing.
Thanks
<p>Can I make this exact circuit but with LED strips that run 12v?</p><p>I want to make a flicker box that can simulate fire for my short films, the only problem with normal ones you buy in stores, they are really really expensive :(</p><p>I appreciatie any answer.</p><p>Dylan</p>
<p>Thanks for the simple but efective code.</p><p>I included the randomSeed(392113) command in the Setup function</p><p>and change the analogWrite commando to analogWrite(ledPin1, random(0,255));</p><p>just to make it more effective and cleaner.</p><p>and</p>
<p>Thanks, I borrowed your approach for a project I'm doing with my son's Minecraft torch from Thinkgeek... enhanced it as a part of my main loop so that it also incorporated a random timer controlling the flicker. Not the most elegant code but it ended up looking very cool!</p><p>Just posting an excerpt of the code, but as you might guess the elapsedTimeSinceOn is millis() now - millis() when the torch was turned on (button press):</p><p>if ((torchLEDState == TORCH_FLICKER) &amp;&amp; (elapsedTimeSinceOn % lastFlickerDelay == 0)) {</p><p> // let's make the torch flicker</p><p> if (DEBUG) { Serial.println(&quot;8 - running flicker routine&quot;); }</p><p> int brightness = random(10);</p><p> int duration = random(10);</p><p> switch (brightness) {</p><p> case 0:</p><p> case 1:</p><p> case 2:</p><p> case 3:</p><p> case 4:</p><p> case 5:</p><p> analogWrite(torchLED_pin, random(120) + 50);</p><p> break;</p><p> case 6:</p><p> case 7:</p><p> analogWrite(torchLED_pin, random(120) + 85);</p><p> break;</p><p> case 8:</p><p> case 9:</p><p> analogWrite(torchLED_pin, random(120) + 135);</p><p> break;</p><p> }</p><p> switch (duration) {</p><p> case 0:</p><p> case 1:</p><p> case 2:</p><p> case 3:</p><p> case 4:</p><p> lastFlickerDelay = 100;</p><p> break;</p><p> case 5:</p><p> case 6:</p><p> lastFlickerDelay = 200;</p><p> break;</p><p> case 7:</p><p> case 8:</p><p> lastFlickerDelay = 500;</p><p> break;</p><p> case 9:</p><p> lastFlickerDelay = 50;</p><p> break;</p><p> }</p><p> }</p>
<p>not tried this yet, too busy at moment, but the effect looks really good. well done and thanks for sharing</p><p>John :)</p>
Hello, when i try to upload the code to the arduino i get this error message. <br>Collect2.EXE: error: Id returned 5 exit statusError compiling.
What version of the IDE are you using?<br><br>
I am using Arduino 1.6.4
Easy and looks great.
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
Great project - it works great - anyone with an Arduino ought to give it a try. <br>
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
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.
Glad you like it. It's very effective in real life.
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?
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?
Random brightness neet little effect. Try that with a RGB LED.
Actually using RGB LEDs is a nice effect.
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.
Cool :)
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.
You were right! I've fixed it. Thanks.
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!
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!