Introduction: Audio Responsive LED Lights
This project is my attempt to build LED color organ and VU meter both combined. The color of the LED depends on the frequency of the audio signal. The number of rows(i.e, arcs) depends on the amplitude of the input audio signal. This project uses Arduino pro mini,LM358 op-amp,mosfets which are easily accessible to everyone.
Watch the video to see the project in action. Use headphones for clarity. Please ignore my video making skills.
Step 1: Components Needed
Here's the list of all the components and stuffs needed to build this project.
1. Common Cathode RGB led (x72)
2. P-channel MOSFET (x3)
3. N-channel MOSFET (x5)
4. UF4007 diode (x3)
5. NPN Transistor(x3)
6. LM358 op-amp ic (x2)
7. 1K Ohm resistor (x8)
8. 10K Ohm resistor (x11)
9. 100K Ohm resistor (x3)
10. 68K Ohm resistor (x2)
11. 10K trim pot (x3)
12. 200K trim pot (x1)
13. 1uF electrolytic capacitor (x1)
14. 4.7uF electrolytic capacitor (x2)
15. 10nF Ceramic Capacitor (x3)
16. 6.8nF Ceramic Capacitor (x2)
17. 68nF capacitor (x1)
18. 100nF capacitor (x2)
19. 7805 regulator (x1)
20. Screw Terminal 1*02 (x2)
21. AUX female pin (x1)
22. DC jack female (x1)
23. Arduino Pro Mini (x1)
25. 8 DIP base(x2)
26. Female headers.
5 mm plywood( 240 mm * 240 mm )
Frosted / Clear Acrylic 3 mm (110 mm * 180 mm)
M3 Metal spacers 40 mm (*2) and 10 mm(*4)
M3 nuts,bolts and washers.
Step 2: LED Sign PCB
At first I started this build by making a LED sign. I used the free EasyEDA software to create the PCB design and I ordered the PCBs from JLCPCB services. You can access the PCB files here.
if the link to the PCB files is not working. Please follow this link : https://easyeda.com/ManojBR/led-color_organ_vu_met...
After getting the PCBs, I soldered LEDs to it. The LED pads have very little clearance between them. So, it can be a bit difficult to solder them. I recommend you to follow the method that I used.
i. Insert the LED pins completely into the holes.
ii. Solder one of the extreme end pins.
iii. Heat the soldered pin and position the LED properly.
iv. Trim off the excess length of the leads of all the pins.
v. Finally solder all the pins with minimum soldering lead.
(see pictures for better understanding).
Step 3: Driver Circuit:
The driver circuit's working is very simple. The circuit consists of four op-amps in which three of them are used as active filters and other as a non-inverting amplifier. The filter circuit gives the frequency data to the arduino.The non inverting amplifier gives the amplitude data of the audio signal to the arduino. After receiving the data, arduino controls the LEDs through the MOSFETs.
The schematic can be accessed from here : https://easyeda.com/ManojBR/driver-for-led
I made the circuit according to the above circuit using 2 dot PCBs. I built the filter circuit on a small dot PCB. Then I built the rest of the circuit on a strip board. It was a very simple one to build.
Arduino MOSFET LED driver:
The Led driver circuit consists of 5 n-channel MOSFETs and 3 p-channel MOSFET. N-channel MOSFETs are connected to the common cathode of the LED. 5 of these mosfets are connected to the 5 different rows of LEDs. These mosfets are just used as switches which will be in on state if its gate is pulled HIGH.
The 3 P-channel mosfet controls the brightness of Red, Green and Blue LEDs. Since P-channel is will be in on state if its gate is pulled LOW, a NPN transistor is used to drive these mosfets. The PWM output of the arduino controls these MOSFETs.
The mosfets acts as a voltage controlled resistor when the gate-to-source voltage is less than its pinch-off voltage. This characteristic of the mosfet is utilized to regulate the current through LEDs to control its brightness. Vcc1 is the voltage supply given to the whole circuit. This voltage must be greater than 7.5v. This input voltage is connected to the input of the buck converter and its output is taken as Vcc2.
1.Connect one of the PWM pins (R_PWM,G_PWM or B_WM) to 5v and set Vcc2 to 4v.
2.Connect the LEDs to the driver board.
3.Measure the current draw of the LEDs(make sure only one color is turned on).
4.Now adjust the Vcc2 such that the current draw is 250mA(make sure that the Vcc2 doesn't exceed 4.5v).
The voltage Vcc2 that I got was around 4.2v. This voltage sets the maximum current that one p-channel mosfet can supply to the LEDs.
Step 4: Filters and Peak Detectors:
Filters are the circuits which allow specific range of frequency signal to pass through them. Low pass, High pass and band pass are few types of filters.
basically, there are two categories of filters Active and Passive filters.
Passive filters are just combination of resistors and capacitors(frequently called RC network). Where as the active filters consists of RC networks and an Op-amp. The number of RC networks are usually called number of pole.
There are many types of active filters whose frequency response curve is as in the photo above. Out of all the types of active filters Chebyshev filter seems to have good frequency response. So, I chose this filter circuit for my project and followed the table given with the circuit for calculation purposes.
Reference: Art of Electronics 3rd edition.
The formula of the cut-off frequency is given by,
fc = 1/(2*pi*R*C*Cn)
where, fc is cut-off frequency in Hz.
R is resistance in ohms.
C is capacitance in farads.
Cn is a factor which depends on the type of filter we are using and that is equal to 1.231 for Chebyshev.
The gain of the Op-amp should be K = 1.842 for Chebyshev filter, I have chosen R as 10K ohms. So, the trim pots R6,R13 and R20 should be adjusted (K-1)R = 8.42K ohms in the driver circuit.
Low pass filter:
Low pass filter allows the signals of frequency less than the cut-off frequency of the filter circuit to pass through it. The graph of amplitude v/s frequency of the output of the low pass filter.
According to the formula given above, I chose the R1=R2 and C1 = C2 as 68K ohms and 10nF. Which gives the cut-off frequency as 190 Hz(approx. 200 Hz).
High pass filter:
High pass filters allow the signals of frequency higher than the cut-off frequency of the filter circuit to pass through it. The output of the high pass filter is as shown in the graph above.
I used the same formula again to choose R1=R2 and C1 = C2 as 10K ohms and 6.8 nF. which gives the cut-off frequency as 1.9 KHz(approx. 2kHz).
Band pass filter:
Band pass filter is combination of both low pass and high pass filter circuit. Band pass filter circuit has 2 cut-off frequency upper(fh) and lower(fl). The output of the band pass filter as shown in the graph above. The low pass part of the band pass filter determines the upper cut-off frequency and the high pass part determines the lower cut-off frequency.
Again using the same formula and R1 and C2 as 10K ohms and 6.8 nF, we get upper cut-off frequency as 1.9KHz. Once again taking R2=R3 and C1 as 10K ohms and 68 nF, we get lower cut-off frequency as 190Hz.
This makes the band pass to allow signals between 190Hz-1.9KHz(approx. 200Hz-2kHz).
Peak Detector Circuit:
Peak detector circuit is just a diode whose anode is connected to the input and cathode is connected to a capacitor. The other end of the capacitor is grounded. The output from the peak detector is taken across the capacitor. A resistor of few 100K ohms is used to discharge the capacitor.The value of the capacitance decides the sensitivity of the peak detector. More the capacitance less is the sensitivity. Therefore the capacitor for high frequency should be less and vice-versa.
The output from the filter circuit is fed to the peak detector and output of this is connected to the arduino. The working of this circuit is very simple. Initially, when the capacitor is fully discharged, It charges up to the peak voltage through the diode and discharges slowly through the resistor giving peak voltage as the output until it discharges to a voltage equal to the input voltage and starts charging again. This cycle repeats continuously. You can understand it in more detail in this video:
Step 5: Programming and Tuning:
I wrote the code for the arduino using arduino IDE, which should be installed before uploading the code. The code is very simple, at first we will declare all the pins and then their readings are assigned to the corresponding variables. Then, in the main section we will set all the output pins to low and start the serial monitor. Nevertheless in loop section we will read the input from the op-amps. After reading, the readings will be printed on the serial monitor. Then the readings are constrained and mapped to values from 0 to 255. This value is then outputted as PWM for corresponding color.In the code I have set low frequency to red, mid frequency to green and high frequency to blue.
Before, you can enjoy the final result some tuning has to be done. To do this you have to follow these steps
1. Connect the arduino to the USB, AUX pin to audio output of your device.
2.Open the serial monitor on arduino IDE(after uploading the code) and also online tone generator(link below).
3.Now play the music with high volume and set frequency to 100Hz. After doing so adjust the R3 trim pot so the reading low-freq becomes maximum (approx 500 - 700 for lm358 ).
4.Set frequency to 200Hz and again adjust the same trim-pot to get reading low-freq near to 160-170.
5.Set the frequency to 10KHz and adjust the R15 trim pot so the reading high-freq becomes maximum(approx 400-700).
6.Set frequency to 2kHz and adjust the same trim pot to get high-freq near to 150-170.
7.Set frequency to 1kHz and adjust the R9trim-pot in such way that the mid-freq reading is just below maximum.(I got approx 200).
The output of the band-pass filter(mid-freq) will be usually less than the other two. But, that's not a problem I have rectified that in code. If you have any doubt in this step, feel free to ask in comments section.
R23 is thetrim-pot which adjusts the sensitivity of the number of rows. It sets the gain of the amplifier which gives the amplitude data to the arduino. The tuning of this is very simple just repeat the step 1 and 2 given above and set volume max at any frequency. Now, you will have to adjust the pot such that max output of op-amp should be just below 710-715.
You can adjust the trim-pot afterwards, if all the rows are lighting for small amplitude or if any of them are not at all lighting up.
Now the project is almost complete,It just needs final casing and wiring.
Step 6: Casing and Wiring.
To make things easier, I have made a wiring diagram. You can follow that to wiring.
For the casing I took 2 12*24 cm 5 mm plywood. I coated one side of it with varnish to give it a polished look. Then I placed the LED sign PCB on center on one of the pieces and drilled the holes for mounting. Afterwards, I soldered some wires on back of the PCB and passed them through a hole that I made at the center of the front piece. After doing that, I mounted the PCB in its position and then I used some small metal spacers. On top of that spacers I wanted to mount a frosted Acrylic sheet, but I didn't have one. So, I took one of the clear acrylic sheet which is slightly bigger than the PCB and sanded it on either surfaces to give it frosted look. Then I placed it on top of the spacers and mounted it.
I repeated the same drilling and mounting procedure for the driver circuit and buck converters to mount it on the back piece. After doing all these things I mounted the back piece to the front piece with some 40 mm metal spacers. Now, the casing and wiring was done.
Step 7: Final Words:
This project was possible because of the LCSC company, which is one of the fastest growing suppliers of electronic components in China. LCSC has been committed to offering multitudinous, genuine and in-stock items, since its founding in 2011. Aiming to provide the whole world with more superior parts from Asia. More details please visit: https://lcsc.com/
It is because of their support that I was able to complete this project. So, I recommend you to buy the components from them if you make one of this yourself. I have given the links for all the components above.
If you like this project, then please VOTE for the same in the contests.
Thank You! so much for going through this project.
Participated in the
Arduino Contest 2019