Открытый проект со схемой, платой и документацией.
NeoCandle is a simple tea light candle simulation based on ATtiny25/45/85 using 5mm NeoPixels (WS2812), LDR light sensor (GL5528) and IR remote receiver (TSOP4838). It can be controlled by an IR remote control with two buttons and has a timer mode for automatic shutdown after a set time as well as an LDR mode in which the candle is automatically switched on and off depending on the intensity of the ambient light.

The simulation code is based on the great work of Mark Sherman. With most LED candles, the random flickering is rather silly and lacks the spooky element of candlelight: shadows cast by the candle move because the flame is in motion. With NeoCandle, four NeoPixels are arranged in a square, the intensity of the four LEDs forms a "center" of light balance that can be moved around smoothly.
This 'physics-based' candlelight has the following properties:
The control of NeoPixels with 8-bit microcontrollers is usually done with software bit-banging. However, this is particularly difficult at low clock rates due to the relatively high data rate of the protocol and the strict timing requirements. The essential protocol parameters for controlling the WS2812 NeoPixels (or similar 800kHz addressable LEDs) can be found in the datasheet.

Fortunately, the timing is nowhere near as strict as the data sheet suggests. The following timing rules can be derived from the excellent articles by Josh Levine and Tim and should work with all 800kHz addressable LEDs:
|Pulse|Parameter|Min|Typical|Max|
|:-|:-|-:|-:|-:|
|T0H|"0"-Bit, HIGH time|65 ns|350 ns|500 ns|
|T1H|"1"-Bit, HIGH time|625 ns|700 ns|8500 ns|
|T0L|"0"-Bit, LOW time|450 ns|800 ns|8500 ns|
|T1L|"1"-Bit, LOW time|450 ns|600 ns|8500 ns|
|TCT|Total Cycle Time|1150 ns|1250 ns|9000 ns|
|RES|Latch, LOW time|9 µs|50 µs|280 µs|
Apart from T0H, the maximum values can be even higher, depending on when the NeoPixels actually latch the sent data (with some types only after 280µs!). This also makes it possible to work without a buffer and thus without the use of SRAM. The software essentially only has to ensure that T0H is a maximum of 500ns and T1H is at least 625ns, so that the pixels can reliably differentiate "0" from "1" and that the time between sending two bytes is less than the latch time. Assuming that the microcontroller runs with a clock frequency of 8 MHz, the following simple bit-banging function for the transmission of a data byte to the NeoPixels string was implemented:
Это краткое изложение проекта. Полную версию с подробностями смотрите на сайте оригинала: https://oshwlab.com/wagiminator/attiny85-neocandle-dip