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.
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.
Comments