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

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

Project Source on GitHub Return to the LEAP Catalog
About LEAP

LEAP is my personal collection of electronics projects - 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.

Projects are often inspired by things found wild on the net, or ideas from the many great electronics podcasts and YouTube channels. Feel free to borrow liberally, and if you spot any issues do let me know or send a pull-request.

NOTE: For a while I included various scale modelling projects here too, but I've now split them off into a new repository: check out LittleModelArt if you are looking for these projects.

Project Gallery view the projects as an image gallery Notebook reference materials and other notes Follow the Blog follow projects and notes as they are published in your favourite feed reader