Arduino Fire Effect

About using Arduino to make a fire effect. Use this to make model camp fires, fires in model boilers, and miscellaneous fires around your layout. You can also use it to illuminate candles and fire places.

This tutorial is part of our series about using Arduino without having to learn how to program. For more go to Arduino Projects.

LEDs For A Fire Effect

LED Fire In Boiler
How To Make A Scale Model Fire Effect

The sketch below uses up to 6 LEDs connected to an Arduino Microcontroller.  Vary the color but generally use red and yellow.  Some people add some blue.

For small fires, such as in ho scale buildings, use SMD LEDs. For larger fires, use larger LEDs.  3mm and Christmas light LEDs are good for HO scale layout camp fires and boilers. Increase the number and size for a fire place.  Backl ighting with a mirror or foil increases their effect.

Use as many of the connections as you wish.  If you want, for example,  only four leds, only use 4 connections

The LEDs flicker at different rates.  That allows you to choose how your fire looks.

 

 

 

Arduino LED Fire
Arduino Fire Effect

Watch this in action on this video.  Either click on the link or the image to the left.  Arduino Fire Effect

How To Connect LEDs

The wiring diagram for a typical 3 LED fire.  For more LEDs just follow this pattern.

LED Fire Effect Fritzing Diagram
LED Fire Effect Fritzing Diagram

An Arduino nano or clone is all that you need.  Of course an Uno or Mega can be used.

Arduino Fire Effect Sketch

This is simple for 3 LEDS.  All flicker at the same rate. You can change that by adjusting the figures in “random”

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

 

This is for up to 6 LEDS.  You can add more LEDs by adding more pins,

// LED Fire Effect
int ledPin1 = 3;
int ledPin2 = 5;
int ledPin3 = 6;
int ledPin4 = 9;
int ledPin5 = 10;
int ledPin6 = 11;
void setup()
{
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
pinMode(ledPin6, OUTPUT);
}
void loop() {
analogWrite(ledPin1, random(120)+50);
analogWrite(ledPin2, random(100)+0);
analogWrite(ledPin3, random(120)+100);
analogWrite(ledPin4, random(120)+50);
analogWrite(ledPin5, random(120)+50);
analogWrite(ledPin6, random(120)+50);
delay(random(100));

}

 

You Are Invited To Ask Questions And Make Comments.

Click here.

Tell others about this information by using one of these services. Thank you for the support.
Scroll to top