Hello World!
blog for everything
EntriesAbout Me

ATtiny85 Candle

By bshabanov
Published in Electronics
December 28, 2020
1 min read

This project utilizes attiny85 as a candle.
PCB is built from two single-sided copper boards.
It flickers for about 15 minutes, and after that, it goes off.
It can be lit again with a button for another 15 minutes, and the cycle repeats till the battery die.
The idea comes from conventional candles mixed with electronics :)
It still looks very realistic, it cannot burn out, and it powers off automatically.
Additionally, I printed 3d enclosure, and add some baking paper as a light diffuser.
The final result is pretty convincing.


About the code

To emulate fire, I started testing with no particular idea in mind. In the beginning, I try to send some analog values for the RED and GREEN channel on the led with a fixed delay. But in some cases, red was too low and green was high, so the light looks greenish. I fix this issue by selecting a random value for the green between 0 and the red value. In this case, the light was still able to go from almost zero to maximum brightness, and again it wasn`t realistic. The solution I found most natural was to tweak the light with a random step(in this case, between -32 and 32) for the red channel. Like that, the led will never do an enormous jump between min and max value.The green value is formed from the red with a little tweak.

// Initialize the red value
int step = random(128, 255);
for (long i = 0; i < 90000; i++) {
// Smooth increase or decrease value
step += random(-32, 32);
// Never go below 128
step = max(128, step);
// Never go above 255
step = min(255, step);
// Tweak the green value
int g = step - random(0, 32);
analogWrite(RED, step);
analogWrite(GREEN, g);
// Random delay to eliminate artificial look
delay(random(8, 16));

With 3D enclosure:

The box is printed in 3 parts

Bottom - which is the main part. Top - threaded cap that presses the candle to the bottom Ring - If you want to use a diffuser(baking paper), you can slice 33mm diameter circle paper and add it between the top and the ring part.

3D printed enclosure

Short Video:


Previous Article
Wio Terminal Controller
Next Article
Acrylic Led


Discover the world



Related Posts

8bit Bitwise calculator
August 09, 2020
1 min
0x48 0x65 0x6c 0x6c 0x6f 0x20 0x57 0x6f 0x72 0x6c 0x64 0x21
2021 and still discovering the world