Tuesday, December 24, 2024

Music-Operated RGB LED

Here, RGB LED light intensity and colour change with the rhythm and volume of music. It is a great idea to have such a lighting system at home, gym or music school. This circuit is based on ATmega8A microcontroller (MCU). The author’s prototype is shown in Fig. 1.

Fig. 1: Author’s prototype

Circuit and working

The circuit diagram of the music-operated RGB LED is shown in Fig. 2. It is built around electret microphone (MIC1), 5V voltage regulator 7805 (IC1), op-amp LM358 (IC2), ATmega8A MCU (IC3), RGB LED and a few other components.

Circuit diagram of music-operated RGB LED
Fig. 2: Circuit diagram of music-operated RGB LED

Connector CON1 is for connecting 9V power supply. Capacitor C1 is the electrolytic capacitor to reduce low-frequency noise at the input of 7805 (IC1). C3 is the ceramic capacitor to reduce high-frequency noise in the 5V power supply rail.

- Advertisement -

A pre-amplifier built around op-amp LM358 (IC2) is used to amplify the audio signal received from MIC1. It is configured as a trans-impedance amplifier, and it converts current to voltage level. It is designed to operate with 5V single power supply.

Capacitors C2 and C4 are used to reduce noise in the power supply rails. Resistor R1 is the biasing resistor that sets the current consumption of the microphone. C6 is the coupling capacitor. R1 and C6 together form a high-pass filter.

- Advertisement -

Resistors R3 and R6 form the voltage divider network for biasing the non-inverting terminal of IC2. R2 is the gain-setting resistor. C5 is the feedback capacitor for stable operation. R7 provides the discharge pathway to prevent the build-up charge on the coupling capacitor (C7).

If charge is allowed to build on C7, it can cause thumps when connected to further stage. Output pin 1 of IC2 is connected to ADC5/PC5 (pin 28) of MCU IC3 through R5 and C7.
IC3 is clocked with an internal RC oscillator and, hence, an external crystal is not used. C9 is the ceramic capacitor to reduce noise across 5V and GND terminal of IC3. C10 is connected to AVREF pin of IC3 for 2.5V reference voltage. Since MIC1 output is connected to pin 28 of IC3, the MCU processes the input audio signal and converts the sound signal to 10-bit ADC value. And, RGB LED glows according to sound level.

Resistor R8 sets the current flowing through the blue LED. Current can be calculated using the following formula:

Current = (voltage – forward of blue LED)/R8
= (5V-3.3V)/120E
= 14.16mA

Similarly, current through the green LED will be 14.16mA, since forward voltage of green LED is also 3.3V. Forward voltage of red LED is around 1.9V, so current through it is around 14mA.

Software

The program (musicRGB.c) is written in AVR C and compiled using Atmel Studio version 6.2. Hex code generated is burnt into IC3 using a suitable programmer board. Fuse bits settings are not required during programming of IC3.

Download Source Folder

Construction and testing

An actual-size PCB layout for the music-operated RGB LED is shown in Fig. 3 and its components layout in Fig. 4.

PCB layout of music-operated RGB LED
Fig. 3: PCB layout of music-operated RGB LED
Fig. 4: Components layout for the PCB

Download PCB and component layout PDFs: click here

Working of the circuit is simple. First, assemble the circuit on the PCB. Burn the hex code and insert IC3 in its socket in the PCB. After assembling the components on the PCB, place this device near a sound source, such as a loudspeaker.

Power on the circuit and the red LED in RGB LED will switch on. If the microphone is kept near a loudspeaker and music is played, mixed colours in RGB LED will be observed. If the volume of the music is increased to mid-range, purple colour will be seen. When music is played at its peak, white colour will be seen in the RGB LED. You can use a diffuser or translucent paper on the RGB LED for a better colour display.


K. Visweswara Rao Kalla is an electrical and electronics engineer. His interests include robotics and analogue circuit designs

SHARE YOUR THOUGHTS & COMMENTS

EFY Prime

Unique DIY Projects

Truly Innovative Electronics

Electronics News

Latest DIY Videos

Electronics Components

Electronics Jobs

Calculators For Electronics