← Back to projects
Fire

Fire

A single flickering LED already makes a nice candle. But a real fire is not one flame — it is many little flames flickering out of sync, in different colors and intensities. If we drive several LEDs independently, each with its own random flicker, the result looks surprisingly like a small campfire.

This project extends the candle idea into a full flame effect using multiple LEDs.

Source code: projects/fire/Fire.java

What You Will Learn

  • How to drive multiple LEDs with independent software PWM
  • How to layer several random effects into a single scene
  • How to keep timing consistent while running several "channels"
  • How color mixing can suggest depth, even with just a few LEDs

Components

  • Raspberry Pi
  • 3 or more LEDs — a mix of red, orange and yellow works best
  • 1 × 220Ω resistor per LED
  • Breadboard
  • Jumper wires
  • Optional: crumpled tissue paper, wax paper or a small paper "log" to diffuse the light

Wiring

  1. Connect each LED's anode (longer leg) to its own GPIO pin through a 220Ω resistor.
  2. Connect every LED's cathode (shorter leg) to any GND pin on the Pi.
  3. Cluster the LEDs together on the breadboard so their light mixes.
  4. Optionally cover them with tissue paper or arrange small paper "logs" around them.

How It Works

Each LED is driven with its own software PWM cycle, and each has an independently drifting target brightness. Red LEDs stay brighter on average (the base of the flame), yellow LEDs flicker more nervously (the tips), and orange LEDs sit somewhere in between.

Because each LED is doing its own thing, when you look at the whole cluster it does not look like blinking — it looks like a small fire that is alive.

Possible Enhancements

  • Add more LEDs and arrange them vertically for a taller flame
  • Use RGB LEDs so each "flame" can pick its own color
  • Add a fan or piezo buzzer for crackling sound
  • React to a microphone: the fire "flares up" when you blow into it
  • Fade the fire in and out to simulate lighting and extinguishing

Why It Matters

Combining several small, imperfect signals into one convincing effect is a core trick of embedded and creative coding. Once you can do it with LEDs, you can apply the same idea to motors, sounds, LED strips and displays. It is where hardware starts to feel less like electronics and more like magic.