It all started with one very interesting post about creating a laser show . It was just under the new year and it was necessary to think of something for the impending New Year's party. And the laser show, driven by music, was what the doctor ordered! Chinese pointers burned one by one, and their brightness was very mediocre. Just somewhere I found an article on how to make a laser pointer from a DVD-drive. The new year has long passed, the LPT port burned down, but then the ATTiny2313 I ordered and a bunch of other electronic components arrived. A lot of time passed for the soldering iron, a lot of converted boards, assembled rakes ... In the end I decided to order a powerful RGB LED for 3W. Then the laser show was already working on a 30mW green laser with the help of the Winamp visualization plugin via the COM port. In general, the LED made a huge impression on me, and I decided to add color music to the laser show.
Device
What we have been given: three coolers and a laser for the laser show module; Two powerful 3W RGB LEDs. It is necessary for this business to make a control unit so that he has the opportunity to communicate with the computer via the COM port with a special program.
I’ll say right away that in the end the laser died and no code was even written for the laser show, so from here on it’s all about color music.Also in the scheme there is a USB-port, but it was also not possible to implement.
')
An ATMega8 microcontroller was selected for the control unit. It is easy to program on it, there are a lot of articles on the Internet. The EasyElectronics website helped me especially hard; there I learned how to make simple devices and learned a little circuitry.
I did not have a large selection of LEDs, in fact there was only one option: ARPL-STAR 3W RGB. . It has 6 pins, so each of the three LEDs is controlled separately. In my case, the connection scheme was with a common anode. I must say that the LEDs consume a rather large current - each 350mA at maximum brightness. There are two RGB lamps in total and they are connected in parallel to the same MK outputs, so the current is not very small. For switching, I chose the same uln2003 from the article about the laser show, only I used two leads to each LED of the lamp, since each pin holds only 500mA, so a total of 6 pins. I have to say that the idea was not the best. Although the parameters are fine, but in fact, if the lamps are lit in white with full power, then uln overheats and turns off. I had an idea of a completely different design, which I will write below.
The diagram is a standard kit for the MK, a Molex connector is built in for powering, which provides 12V for laser show coolers and 5V for everything else. You can connect to a computer, but for convenience I used a separate power supply with a molex type output. To program the MC, the standard Gromov programmer was used. But the adapter RS232 <-> UART. In the future, it was planned to do everything via USB, but I used the wrong USB connector on the board, so now I can not find the cable to connect to the computer.
The color of the lamp depends on all three LEDs that are built into it. Color model - RGB. The brightness of each of the LEDs depends on the voltage. So PWM is used to change the brightness of a specific component. Thus, to set the color for the controller, it is enough to transmit three values from 0 to 255, where 255 means maximum brightness. It is worth noting that the lamps are very hot, so you need to put them on radiators.
The MK program was written in C on AVRStudio and it is quite simple: upon the arrival of a byte on UART, it is entered into a queue; in the main loop, the program calls the current command. A command is an index of the procedure in the table that needs to be run. There are only three commands used: simple, clear color and set color. In a simple program it looks if there is data in the queue, and if there is, then the index of the current command changes to what is in the queue. The color setting command takes 3 bytes of data so that it hangs in the main loop while there are 3 bytes in the data queue.
PWM is implemented in software. This was done because there are only three PWM hardware channels in ATMega8, and I needed six: three for laser show coolers and three for lamps.
The printed circuit board is made using the LUT method.
Program
Initially, everything was controlled by a visualization plugin on Winamp. But it was not convenient, because often music listened to VKontakte. It was decided to write in C #, since The application should be purely front-end. After searching the Internet for information about capturing sound, I did not find anything sensible, but I remembered that in the sound card, you can configure the recording device to the conclusion of what is currently playing. So I, using the Bass library, quickly made an example. It also turned out that in C # there is a whole class for working with serial ports - everything turned out to be very simple.
Although the color model of the lamps is RGB for obvious reasons, it is not the most suitable for visualizing music, so the program uses the HSV model. Each color component — color, saturation, and brightness — is independently adjustable. I decided not to be limited only to color music: for each color component, you can choose one of the possible sources: manual input, random value, audio, and copying another component. In manual mode, you can adjust the color, brightness and saturation. With the help of a random mode, you can make a mood lamp (there are settings for the range, frequency of shift and speed of shift). The most interesting mode is of course audio.
Everything is based on the frequency spectrum. The frequency range is selected, which will affect the value of the color components, the signal level is selected (can be reduced, it can be increased), offset, smoothing. You can also use not the signal level, but its change. I usually put it on the brightness of the lamps and it turns out such a stroboscopic effect (the stroboscope, by the way, can also be realized) - with an increase in the signal level, the brightness increases, with a decrease, respectively, decreases. This is where the shift, with which you can adjust the initial brightness, is useful.
What can be done
First, as I wrote above, if you turn on the lamps at full power, they will quickly turn off because of uln. In addition, if the lamps need to be placed at a relatively large distance from the head unit, then you need to use thick wires, otherwise there will be large losses. So I had an idea of a completely different design: to make each lamp as a separate module with its own power supply, its own MK and controls. These modules will be connected to the main device via twisted pair, and the avr tools allow the MC to communicate with each other. So it will be possible to control the lamps separately.
Secondly, it is possible to blink light bulbs not only to music, but also under video, it is possible to make something like AmbLight, and the current architecture allows to make it. Any information on capturing video? The lamps themselves are very bright, especially two, and they only illuminate a room of 35 squares, so you can bring the viewing of photos to a new level! See you pictures from the sea, and the whole room is filled with a pleasant blue tint - beauty!
Conclusion
Much has been done, much remains to be done, unfortunately not in the near future. Finally - the video. Unfortunately, my camera is not distinguished by good photosensitivity, so the video seems that nothing is covered at all. In fact, the effects are very strong, and if you look at the lamps themselves, it puts a lot of pressure on the eyes - the very thing for parties.