Insulation materials Insulation Blocks

Light decoration for the New Year tree or festive hall. RGB LED projects on MK Tsvetomuzika on atmega8 8 channels

Additionally

  • IN: I bought a tape with contacts G, R, B, 12 on it. How to connect?
    A: This is the wrong tape, you can throw it away

    IN: The firmware loads, but the error “Pragma message...” appears in red letters.
    A: This is not an error, but information about the library version

    IN: What should I do to connect a ribbon of my own length?
    A: Count the number of LEDs, before loading the firmware, change the very first setting in the sketch, NUM_LEDS (the default is 120, replace it with your own). Yes, just replace it and that’s it!!!

    IN: How many LEDs does the system support?
    A: Version 1.1: maximum 450 pieces, version 2.0: 350 pieces

    IN: How to increase this number?
    A: There are two options: optimize the code, take another library for the tape (but you will have to rewrite some of it). Or take Arduino MEGA, it has more memory.

    IN: Which capacitor should I use to power the tape?
    A: Electrolytic. The voltage is 6.3 Volts minimum (more is possible, but the conductor itself will be larger). Capacitance - at least 1000 uF, and the more the better.

    IN: How to check the tape without Arduino? Does the tape burn without Arduino?
    A: The address strip is controlled using a special protocol and works ONLY when connected to a driver (microcontroller)

  • YOU CAN ASSEMBLE THE CIRCUIT WITHOUT A POTENTIOMETER! To do this, use the POTENT parameter (in the sketch in the settings block in the settings signal) assign 0. The internal reference voltage reference source of 1.1 Volt will be used. But it will not work at any volume! For the system to work correctly, you will need to select the volume of the incoming audio signal so that everything is beautiful, using the previous two setup steps.

  • Version 2.0 and higher can be used WITHOUT an IR REMOTE, modes are switched with a button, everything else is configured manually before loading the firmware.

  • How to set up another remote control?
    Other remote controls have different button codes, use the sketch to determine the button code IR_test(versions 2.0-2.4) or IRtest_2.0(for versions 2.5+), available in the project archive. The sketch sends the codes of the pressed buttons to the port monitor. Next in the main sketch in the section for developers There is a definition block for the remote control buttons, just change the codes to your own. You can calibrate the remote control, but honestly it’s too lazy.

  • How to make two volume columns by channel?
    To do this, it is not at all necessary to rewrite the firmware; it is enough to cut a long piece of tape into two short ones and restore the broken electrical connections with three wires (GND, 5V, DO-DI). The tape will continue to work as one piece, but now you have two pieces. Of course, the audio plug must be connected with three wires, and the mono mode (MONO 0) is disabled in the settings, and the number of LEDs must be equal total quantity on two segments.
    P.S. Look at the first diagram in the diagrams!

  • How to reset settings that are stored in memory?
    If you've played around with the settings and something goes wrong, you can reset the settings to factory settings. Starting from version 2.4 there is a setting RESET_SETTINGS, set it to 1, flash it, set it to 0 and flash it again. The settings from the sketch will be written to memory. If you are on 2.3, then feel free to upgrade to 2.4, the only difference is the versions new setting, which will not affect the operation of the system in any way. In version 2.9 there was a setting SETTINGS_LOG, which outputs the values ​​of settings stored in memory to the port. So, for debugging and understanding.

People first started talking about color music consoles as a creative direction for young radio amateurs more than 40 years ago. Then the first versions of diagrams and descriptions of varying levels of complexity for various radio devices began to appear. Today, color music circuits made on microcontrollers are becoming the most relevant; this is what has made it possible to obtain various effects that were previously only dreamed of.

The first circuit of a color music installation is so simple that it can be soldered by a novice radio amateur in 5 minutes. The design allows you to receive color flashes in time with the music playing. We will need a transistor, a resistor, and an LED, as well as a 9V power supply.

The LED lights up to the rhythm of the music playing. But it blinks rather tediously at the current volume level. But I want to separate the audio frequency. Passive filters made of capacitors and resistances will help us with this. They only transmit a fixed frequency, and it turns out that the LED will light up only for certain sounds


The circuit consists of three channels and a preamplifier. The sound comes from the linear output to the transformer, which is necessary for amplification and galvanic isolation. You can do without a transformer if the input signal level is sufficient to blink the LEDs. Resistors R4-R6 regulate the duration of LED flashes. Filters are tuned to their audio frequency bandwidth. Low-frequency - transmits frequencies up to 300Hz, mid-frequency - 300-6000Hz, high-frequency - from 6000Hz. You can take almost any transistors, with a current transfer coefficient of 50 or more, for example KT3102.

The basis of the design of the MK PIC12F629. It controls three bipolar transistors BC547 (NPN 45v 100mA), according to the on/off principle, i.e. they operate in key mode. And these keys control the 12V RGB LED strip in a passenger car, each with its own color.

The MK is programmed to change color when a logical one is received at the PIN_A5 input. The microphone amplifies the signal through transistors VT1 and VT5 and connects to PIN_A5. The microphone is placed near the sound source. The RGB strip is attached to the interior lamps. PIC starts from white and varies in 7 color shades. If you need to control a significantly more powerful load, you can use transistors IRF44Z (50V 55A) or IRF1407 (75V 130A). When assembling, do not forget that different microphones have completely different sensitivity


You can download the archive with the firmware and source code for the MK program from the link above.

The design of this design with original lighting effects is quite simple and reliable. The main element of the device is the PIC12F629 microcontroller. Control of changing the brightness level of amateur radio LEDs occurs due to pulse width modulation. Control codes from the PIC12f629 microcontroller go to transistors VT1 - VT3.

In case of shortage, these transistors can be replaced with KT3102A, KT373. resistances R1-R3 are designed to limit current and protect LEDs. The stabilizer made on the 78L05 chip and capacitances C1, C2 produce a stabilized 5V voltage to power the PIC12f629 microcontroller, and the LEDs are powered from.


Since the design uses RGB LEDs, the glow of each of them is controlled using PWM. This makes it possible to see many different color effects: obtaining various color shades, varying the intensity of the glow, the speed of change, etc.

Toggle switch SA1 is used to select various lighting effects. Pressing once will start the current sequence. When you press the next time, the color change is stopped and the color that turned out to be randomly drawn at the moment of stopping lights up. Double-clicking the button launches the next color effect.

Pressing and holding the button for two seconds will switch the device to sleep mode. Pressing it again for two seconds will reanimate the color and music console.

Instead of a toggle switch, you can use control signals arriving at the second input of the microcontroller and depending on the level of music playback.

The archive with the microcontroller firmware can be downloaded from the green arrow just above.

The programmer circuit and its software are considered

Amateur radio design is used for color accompaniment of music. Light sources of various colors are ultra-bright LEDs. They are controlled by a microcontroller that analyzes the spectral composition of the audio signal.

The microcontroller firmware counts input pulses for certain time intervals and, depending on their repetition frequency, sets high logical levels at the corresponding MK outputs: 100...300 Hz - PB1 (red LEDs), 300...700 Hz - PB0 (yellow), 700...1500 Hz - RV4 (green), 1500...10000 Hz - RVZ (blue).

A supply voltage of 7 to 12 V is supplied to contacts 1 (+) and 2 (-) of the XT1 screw block. To the level of 5 V required to power the MK and op-amp, it is lowered by an integrated stabilizer on the DA2 chip. Resistances R9 - R12 limit the load current of the MK outputs.


MK firmware, assembly details and drawing printed circuit board in the archive at the link above.

When you're a kid, the grass is greener
and the sun is brighter and the air is cleaner

Folk wisdom

I remember when I was a teenager and went to a radio club, the boys would say with a breath: “I wish we could collect color music…”. My uncle, also a radio amateur, showed me a color music diagram. Then it seemed like something absolutely incredibly complicated.
In general, in the Soviet amateur radio environment, color music was a symbol. If you are a young radio amateur and have put together color music, then you start walking around with your nose in the air and groundlessly consider yourself a professional (and if you still understand why and how it works, then you don’t say hello to anyone at all). Every self-respecting radio amateur had to collect it, otherwise he is a loser.

Many years have passed. The soldering iron became covered with a black, indelible coating. The radio components lay sadly upside down on the table. The university course in electronics and circuit design somehow passed me by (I passed something, did something, but I don’t understand how).
One day, when I arrived at my parents’ apartment, I saw my old book on the shelf: “For a Beginning Radio Amateur.” And then my whole life flashed before my eyes: fingers burned by a soldering iron; the sickening stench of steaming aspirin; resistors; diodes; transistors; friend Lech, yelling into the intercom we assembled: “It works!!! Yurik! It works!!!".
So I again discovered the wonderful world of radio electronics.

Started from the very beginning. I understood how receivers, amplifiers, superheterodynes work... For the sake of training, I soldered a couple of “multivibrators” (my wife liked it). And now I come to color music. I tried to assemble it first using LC filters, but it was enough for me to wind only one coil, and then I ruined it. The second one was assembled using RC filters. It was already working and blinking merrily with three LEDs to the music, although I assembled it with a “hinged installation” and the circuit resembled a creepy spider the size of a plate.
But this is the 21st century. And now, wherever you spit, you’ll end up in a microcontroller. If you spit in the washing machine, you get it, you get it in the microwave, you get it in the dishwasher, and soon you won’t be able to spit in the kettle either.

In order to study working with microcontrollers and finally solder something that you can touch with your hands and it will not fall apart, I decided to make a “dynamic light installation”. All! Introduction is over! The most interesting things are ahead.

Target

Set a goal and achieve it!
m\f "Finding Nemo"

Assemble a device that, when a sound signal is received at the input, will light up one of the 8 LEDs, depending on the frequency of the sound signal. If there is no sound signal at the input, the device should blink with all sorts of beautiful effects. It turns out not just color music, but a “dynamic lighting installation”.

Theory

Theoretically, we are millionaires
but practically, we have two whores and one fagot

Joke

Color music is a device that turns on a light bulb of a certain color, depending on the frequency of the incoming sound signal. Those. the device must determine what frequency the sound is at the input and light the light bulb that corresponds to this frequency.
The average human ear perceives from 20 Hz to 20 kHz. In the designed device we have 8 light channels (LEDs).
In the simplest case, you could do this:
20000 (Hz) / 8 = 2500 Hz per channel. Those. at a frequency from 0 to 2500 Hz, one LED lights up, from 2500 Hz to 5000 Hz the second, etc.
But here a very interesting situation arises. If you take an “audio frequency generator” and listen to a sound with a frequency of 2500 Hz, you can hear that 2.5 kHz is a very high sound. With this channel distribution, we will get only 1-2-3 light bulbs, the rest will be extinguished, because There are few very high frequencies in music.
I started searching. What is the distribution of sound frequencies in the average musical composition? It turned out that there are no such studies on the Internet. But I learned that when compressed into mp3 format, frequencies above 15 kHz are stupidly cut. Because they can only be heard on professional equipment, and no professional will listen to mp3. This means we lower the upper threshold to 15 kHz.
But then I miraculously found it.
After reading it, I made for myself the following table of channel frequency distribution:

Frequency range (Hz)Channel number
20-80 1,8
80-160 2
160-300 3
300-500 4
500-1000 5
1000-4000 6
> 4000 7


Development of a schematic diagram

Don't stop me from robbing!!!
Bender. Futurama

I did not develop the circuit from scratch. For what? The Internet is full of color schemes. You just need to steal them, choose the most suitable one and modify them for yourself. Which is what I did. Here is a diagram called “CMU/SDU on a microcontroller (8 channels).”
Only it was on a microcontroller of the PIC family. And after reading smart forums, I concluded that the most adequate microcontrollers for training and in general are AVRs. But no one was going to tear up the scheme “from scratch”. So we make changes:
1. We change the microcontroller from PIC to ATmega16 (I really wanted to do it on ATmega8, but after running around half the city, I couldn’t find them).
2. Change the power source from 12V to 19V. It's not because of coolness - it's because of poverty. I have this power supply from my laptop.
3. We replace all domestic parts with imported ones. Because when you poke a list of domestic elements in the seller’s face, he looks at you like you’re a sheep. Only the transistors will have to be replaced: KT315 with BC847B, KT817 with TIP31.
4. We remove the external “quartz” Qz1 and with it the capacitors C6 and C7. Because ATmega16 has built-in quartz.
5. Remove the S1-S4 keys. No interactivity! Everything is automatic!
6. In the original output circuit, the following mechanism was used. KT315 transistors acted as a key to turn on the LEDs on the board. As the author described, this is kind of necessary to see what is working there, they are not visible to the end user... Superfluous! We remove these transistors and LEDs from the board. We leave only the KT817 transistors, which will turn on the light bulbs visible to the end user.
7. Because We changed the power source from 12 to 19 Volts, then in order not to burn the LEDs, we will increase the resistance of the resistors going from the KT817 transistors to the LEDs.
8. I completely did not understand the purpose of capacitor C4. He was just getting in the way. Removed it.
Here's what came out of it:


How does this work


the basis for the operation of the synchrophasotron,
the principle of acceleration of charged particles by a magnetic field is established,
okay, let's move on
film "Operation Y and other adventures of Shurik"

The circuit contains a single-stage amplifier using transistor Q1. An audio signal (voltage approximately 2.5V) is supplied to connector J9. Capacitors C1 and C2 serve as filters that pass only the alternating component from the audio signal source. Transistor Q1 operates in signal amplification mode: when the EB goes through its junction AC, then with the same frequency, current flows through the EC junction from the power source, through the voltage stabilizer U1.
Voltage stabilizer U1 converts the voltage from the power source into a voltage of 5V and, together with the capacitors connected to it, allows the formation of rectangular pulses. These pulses are sent to INT0 of the microcontroller.


The oscilloscope shows how the audio sine wave signal is converted into a square wave signal.
Now everything is in the hands of the microcontroller. He needs to determine the pulse frequency and, depending on the frequency (according to the plate above), apply a logical one (5V) to one of its pins (PB0-PB7). The voltage from the microcontroller pin goes to the base of the corresponding transistor (Q2-Q9), which operate in switch mode. When voltage occurs at the EB junction of the transistor, the EC junction opens, through which current flows to the LED from the power source.

The inner world of a microcontroller

I have a very rich inner world,
and they only look at my tits!
Quote from the women's forum

Let's now consider what's going on inside the microcontroller. The microcontroller operates at a frequency of 1 MHz (I did not change the default frequency).
We need to count the number of pulses received at the microcontroller input from the audio signal source over a certain period of time. A simple formula from these data calculates the frequency of the signal.

There is one problem with low frequencies: You cannot make this period very large or very small. In a standard musical composition, the frequency of sound changes constantly. If we make the measurement time large (for example, 1 second), then if the sound was 80 Hz for 0.8 seconds, and 12 kHz for 0.2 seconds, we will get a high-frequency sound and lose all the low ones. If we make the measurement time small, then we simply may not have time to measure low-frequency sound, because the measurement time will be less than the frequency of the sound signal.
After sitting with the numbers for 5 minutes, I calculated that a completely acceptable measurement time was 0.065536 seconds.
I received this sign.

Light music on the atmega8 controller attracted attention for its ease of manufacture. When repeating the scheme, there was no need to calculate filters or configure them. There is almost no dependence in volume, and the most important thing is the smooth switching on of lamps (LED diodes), this was important, since simple blinking quickly gets boring.

The light and music circuit on the microcontroller is quite simple, the input signal from both channels is mixed and amplified by the LM358 operational amplifier, then it goes to the AVR "Atmega8" family controller, where it is divided into channels by software.

As you can see from the diagram, the light music has 6 channels (two channels for the three main ones (mid, high, low), they come with BC639 keys, which allow you to connect up to 20 ultra-bright LEDs to each channel.

The printed circuit board is in good quality (in sPlan format), located in the archive. The power is supplied by a small current transformer, which depends on the type of LEDs used.

It is quite acceptable to take individual high-power LEDs or even whole pieces of RGB LED strips. Then the effect will become even more interesting. Just don’t forget to increase the area of ​​the radiators of the transistors of the output switches, because 1 meter LED strip can consume current up to 3A!

Download the firmware for the microcontroller here. And the fuse bits during firmware are shown in the picture:

The device is assembled in a small metal case from a satellite tuner. On the front panel there is a network power button and control LEDs, and on the back of the case there are sockets for connecting LEDs, a sound sensitivity control and audio inputs. Author of the article: MAXIMUS.

ARCHIVE: