Realistic Flickering Flame Effect With Arduino and LED's

140,303

185

45

Introduction: Realistic Flickering Flame Effect With Arduino and LED's

About: Hi, my name is Mike and I am from London, England. I really like to make things and in particular like to do creative things with Arduinos and electronics. Other hobbies include astrophotography and sailing. C…

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.

Step 2: 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

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

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.


8 People Made This Project!

Recommendations

  • Edible Art Challenge

    Edible Art Challenge
  • 3D Printed Student Design Challenge

    3D Printed Student Design Challenge
  • Reclaimed Materials Contest

    Reclaimed Materials Contest

45 Comments

0
rastita
rastita

7 years ago on Introduction

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
0
LightsAction
LightsAction

Reply 6 years ago

Do you have a circuit diagram by any chance?

0
metalhead8711
metalhead8711

Reply 6 years ago on Introduction

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.

0
n71
n71

Reply 6 years ago on Introduction

Hey Rastita, can you provide the code? Superthanx!

0
rastita
rastita

Reply 6 years ago on Introduction

Yeah! for shure.... but it´s almost the same than the original :)

But only using 2 leds, instead of 3...

// LED Fire Effect

int ledPin1 = 5;

int ledPin2 = 6;

//int ledPin3 = 11;

void setup()

{

pinMode(ledPin1, OUTPUT);

pinMode(ledPin2, OUTPUT);

//pinMode(ledPin3, OUTPUT);

}

void loop() {

analogWrite(ledPin1, random(80)+35);

analogWrite(ledPin2, random(120)+135);

//analogWrite(ledPin3, random(120)+135);

delay(random(100));

}

0
n71
n71

Reply 6 years ago on Introduction

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. :-)

0
doktorvortexx

Thanks for the great Instructable! Saved me a bunch of time writing the code myself!

0
0_Nvd_0
0_Nvd_0

12 years ago on Step 4

Very COOL Earthshine. You have invented a very nice thing.

0
DavidB552
DavidB552

Question 7 months ago

question if I put a 5 or 10k pot on the ground line back to the uno could I get varriable brightness of candle or will it break everything ?

0
TheArduinoGuy
TheArduinoGuy

Answer 7 months ago

That will also reduce voltage to the Arduino, so yeah it will totally break everything.

0
DavidB552
DavidB552

Reply 7 months ago

Sorry I mean the ground going from all 3 leds back to the Arduino?

0
TheArduinoGuy
TheArduinoGuy

Reply 7 months ago

It would sorta work but it is not ideal as each LED is meant to have it's own current limiting resistor. It would be a lot easier to do it in code using the PWM functions.

0
sayville882
sayville882

1 year ago

Thanks. Very elegant coding.

0
AJ Sikes
AJ Sikes

2 years ago on Step 4

Brilliant. This is just what I've needed for a dollhouse project. Thanks!

0
RichardR305
RichardR305

2 years ago on Introduction

Thanks for taking the time to create this. It has helped me alot.

0
AKIREEV
AKIREEV

3 years ago

A simple, yet convincing flame effect!

Used it with two 8 mm LEDs (red and orange, but may switch red with something else, not sure yet) and AtTiny85.

I have used two bright LEDs with clear cases, these were the brightest, but had to sand them with sandpaper (fine grit) to make lighting more even.

Thank you very much!

0
payam_sbr
payam_sbr

3 years ago

thanks a lot, i done it for myself and join to its realistic fun's. i want just modify it a bit for adding some random wind effects

0
DylanS63
DylanS63

4 years ago

Can I make this exact circuit but with LED strips that run 12v?

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 :(

I appreciatie any answer.

Dylan