Fork me on GitHub

Project Notes

#696 Flickering Flame Effect

A flickering fire effect with 3 LEDs and adjustable brightness controlled by an ATtiny85.

Build

Here’s a quick demo..

clip

Notes

The circuit demonstrates a flickering flame / fire effect using an ATtiny85. It provides 3 PWM outputs that can be used to drive a suitable selection of LEDs for the application.

The brightness level is adjustable using a variable resistor. The current level is read using an analog input. This is optional if a fixed brightness is satisfactory, and the code can be simplified accordingly.

The code is written to be compatible with an ATtiny, however it can be used with any Arduino provided the appropriate pins are selected.

Circuit Design

Key points:

  • a 100kΩ pot provides the variable brightness control.
  • C1 and C2 stabilise the power supply. They are not really necessary for the LEDs used in the demo, but will protect the microprocessor if higher load LEDs are used
  • the PWM outputs are used to control low-side n-channel FETs rather than directly drive the LEDs. This ensures that current load on the ATtiny85 does not exceed limits (10mA per pin, 60mA total).
  • the LEDs and accompanying current-limiting resistors are just for demonstration purposes - these can be changed as required for a particular application.

bb

schematic

Code Organisation

The main script FlickeringFireEffect.ino runs the main loop. It uses two support classes to orchestrate the effect:

  • level_control.h/level_control.cpp encapsulates reading the brightness input.
  • flame.h/flame.cpp implements the flickering algorithm for a single flame (PWM output).
    • on each update it adjusts the flames brightness
    • the maximum change per update is set by the brightness input
    • the actual change in brightness is determined by the mix value for each flame. This sets the percentage of the new value that is mixed with the old value. Lower values will mean more slowly changing updates

Credits and References

About LEAP#696 LEDArduinoAVR
Project Source on GitHub Project Gallery Return to the LEAP Catalog

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

LEAP is just my personal collection of projects. Two main themes have emerged in recent years, sometimes combined:

  • electronics - usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting
  • scale modelling - I caught the bug after deciding to build a Harrier during covid to demonstrate an electronic jet engine simulation. Let the fun begin..
To be honest, I haven't quite figured out if these two interests belong in the same GitHub repo or not. But for now - they are all here!

Projects are often inspired by things found wild on the net, or ideas from the many great electronics and scale modelling podcasts and YouTube channels. Feel free to borrow liberally, and if you spot any issues do let me know (or send a PR!). See the individual projects for credits where due.