Vermes
Advanced Member level 4
It is a project of Christmas crib with a dynamic LED lighting, music and motion.
Size is 55cm high and 40cm wide. The whole was made mostly of wood and MDF. Nativity scene is illuminated by LEDs, mainly warm-white 3528. The driver has 36 PWM channels with possibility of infinitely variable light intensity. The device is based on two STM32 microcontrollers, one of which (smaller one) is only to generate 24 PWMs (14 hardware, 10 software) and the other (larger) generates the remaining 12 PWMs (hardware) and does all the rest (SD support, audio, inputs).
Applying the gamma correction significantly offsets the nonlinearity of the human eye at lightening/dimming.
The driver is equipped with an SD card, on which there are music files (WAV) and light program files (TXT).
To describe the sequence of light, script “language” was created, which consists of commands such as:
- DIMM (lightens/dims the channel to set brightness at a given time)
- DELAY
- BLINK (a combination of two DIMM commands and DELAY)
- GOTO
- LOOP (making block a specified number of times)
There can be few sequences of light and they will be performed in parallel. This allows to blink stars in loop and in another “thread” blinking lights on the Christmas tree. It is possible to enable/disable the “thread” from the “language”.
The driver also plays music recorded on the SD card (WAV file 32KHz) via digital to analogue converter 12-bit, a simple amplifier and a small speaker 1W. Although 12-bit resolution, the quality of sound is fully satisfactory.
The light program can be synchronized to music, with the option of new “language”, time (relative or absolute) can be given, and commands to be executed then.
One of the PWM channels was used to control the DC motor, which rotates the wheel with figures. By using optocouplers, the figures may be stopped in certain positions (there are several digital inputs).
The whole is powered by 5V (power consumption is about 2-3W, depending on the number of LEDs attached). Unfortunately, you need to use a second power supply to the amplifier AUDIO, because digital part introduced terrible noises.
Synchronizing one Christmas carol with light takes about 1 day of work. Audio editor and a simple program on PC (thanks to which you can play light program without need to copy it to the SD card) make the synchronization easier.
Video of Christmas crib:
This is a fragment of the script describing the light program. Colouring was made by a free editor Notepad++, where your own “language” may be defined.
Link to original thread – Szopka Bożonarodzeniowa LED+AUDIO+MOTION