Introduction: RGB Backlight + Audio Visualizer
Welcome to my Instructables on how to build a RGB LED backlight for e.g. the back of your TV or desk.
The Schematic itself is very simple since the WS2812 LED Strips are very easy to interface with e.g an Arduino Nano.
Note: that you do not have to use the additional MSGEQ7 Audio Analyzer circuit if you only want the LED Backlight without audio visualization.
I provided a detailed list of the used parts and where you can buy them:
- Arduino Nano/Uno ( Amazon / AliExpress )
- WS2812 RGB LED Strip ( Amazon/ AliExpress ), note that IP stands for the protection (e.g. waterproof if you need) and the number stands for how many LEDs per Meter the strip has ( important for power supply)
- 5V Power Supply ( Amazon )(depens how many LEDs strip has) -> each LED takes ~20mA, the strip used in this instructable has 45 LEDs (30 per Meter) so I need 45*20mA ~ 1,5Ampere supply (Arduino,MSGEQ7 need some too), I linked a power supply which provides 3A which is definetely enough for us now
- 3.5mm Audio Jack ( Amazon / AliExpress )
- Potentiometer 10kOhm ( Amazon / AliExpress )
- Push Button ( Amazon / AliExpress )
- Resistor (1x 10kOhm, 1x 220Ohm, for MSGEQ7: 2x100kOhm)
- Capacitors (1x 1000yF Electrolytic ( Amazon / AliExpress ) , 2x 10nF , for MSGEQ7: 2x 0.1yF , 1x33pF ( Amazon / AliExpress )
- Simple Diode (Amazon / AliExpress )
- DC Jack ( Amazon / AliExpress )
Step 1: Build the Schematic
Main Schematic:
So to interface the WS2812 Strip with an Arduino is pretty straight forward using the Adafruit_NeoPixel library.
The LED Strip has 3 Pins: VCC, DATA, GND. VCC is connected to 5V, GND to Ground and the DATA Pin in the middle is connected to LED_DATA Pin D6 on the Arduino. Now every LED on the Strip has an WS2812 chip on it which takes in the Data it receives from the Arduino and passes it on to the next LED, therefore we only need to feed the Led data once to the first LED on the strip.
The logic of the Push Button to change the modes and the Potentiometer to control Brightness is explained in the next Step.
The exact Schematic can be found in the Screenshot of the fritzing file which is also available to download.
Note that it is very important to only connect the Arduino 5V Pin to the Power Supply via the diode , so that the Arduino is not damaged if we plug in the USB Cable to program it. The 10nF and 1000uF is also for safety reasons, so that there won't be any Power shortages.
For the MSGEQ7 Circuit:
This is the most common Circuit to connect a MSGEQ7 to an Arduino. This is also where you need the 3.5mm audio Jack. The middle pin of most audio Jacks is GND, the pins on the left/right are the stereo channels which connect via an 10nF capacitor to the Signal In Pin of the MSGEQ7 as shown in the schematic. You can additionally add a potentiometer to the Signal In Pin to control the sensitivity of the Audio Signal, but is really not necessary. The MSGEQ7 is connected to the Arduino with Analog Out pin connected to A1 (MSGEQ_OUT), Strobe Pin to D2 (STROBE), Reset Pin to D5 (RESET).
Attachments
Step 2: The Code
GitHub Link to complete Sketch:PhilKes/RGB_Audio_Backlight
Notes on the code:
In the code we declare the WS2812 Strip object with a new Adafruit_NeoPixel object, passing in the number of Leds (change NUM_LEDS for you setup), the Arduino Pin connected to the LED_DATA pin, and the coding type + speed of the color values transmission.
Once this is done we set the default Brightness in setup() via setBrightness(0-255) and turn on the Strip with begin(). We can now set each individual Pixel/LED to a specific RGB Color with setPixel(LED, Color). When we are done set all LEDs to new values we update the strip with strip.show(). That is basically all the code logic we need to programm any animation we want. Now to actually control the Animations/Modes we add a Push Button / Tactile Switch to the Arduino. We Therefore connect one end of the Button to VCC and the other to Arduino Pin D3 and with a 10kOhm resistor to GND. We attach an Interrupt to this Pin in the setup(), which triggers a call to the changeMode() method every time we press the button. In changeMode() we simple toggle to the next mode and tell the current animation to break. Once that happens the loop() is newly executed and will play the new Animation/Mode.
The provided Animations include: Rainbow color fade, Red, Green, Blue, White Color , Music analyzer mode
Additionally I added a 10kOhm Potentiometerto control the brightness of the Strip. the method checkBrightness() checks the output of the Potentiometer connected to Pin A2 (middle Pin of Potentiometer) and updates the Strip's brightness accordingly.
For musicAnalyzer() mode via MSGEQ7 :
This mode visualizes the Audio Signal connected to Signal In of the MSGEQ7. The MSGEQ outputs a analog Signal showcasing a single audio band ( 8 Bands, from Low to High frequencies). The musicAnalyzer() method gets the current values of the audio bands by resetting the MSGEQ and then buffering the analog values provided. The band being outputted can be changed by putting a high flank on the Strobe Pin. After all the 8 Bands have been buffered the method shifts all the LED Pixel values one backand calculates the new Value for LED 0. The color is comprised of : Low frequency(Bass) Red Color, Middle frequency Green Color and High frequency Blue color. The shifting of the value before loading the new value gives us a nice smoothly timed animation.
Step 3: Setup Audio on PC
To get your music/audio fed into the MSGEQ7 but still having your music play on your speakers, you either have to use the RealtekHD Stereomix feature or connect the MSGEQ Audio Input to e.g. rear speaker output of your soundcard/motherboard.
To enable the Stereomix in Win10, right click the speaker icon on the bottom right and click "Sounds", here you can activate Stereomix in the "Recording" Tab (right click -> activate). If the Stereomix is not visible, right click an choose "Show disabled devices". Now open the settings for the Stereomix and tell it to listen and copy the audio of your main Speakers.
If you want to use the rear speaker output, open the settings of you main speaker in the "Sounds" menu, Tab "Improvements" and then select "Environment" from the list and choose "Room" in the dropdown menu below.
This now enables parallel audio output of your speakers and the MSGEQ7.
Step 4: Notes
Since the schematic is no that complicated nor big in size I managed to put the entire circuitry into a little 3D printed case under my desk with holes for the USB connector, Audio Jack, DC Jack, Potentiometer and Push Button. You can simply use male/female pin headers and connect the 3 Cables to the WS2812 Strip via Jumper cables.
25 Comments
Question 1 year ago
How do you modify the code if you just want the lights to pulse to the music and not show the spectrum?
Question 3 years ago
i cant get this to work at all i the lights are white all the time?
Answer 3 years ago
Hi you probably have the MSGQ7 1902 chip.
Question 3 years ago
Hi @PhilKey,
I made it, can you help me with the music visualizer? So it just white light right now with dimming via potemtiometer working. If I pull the A1 connection out it sometimes makes white light flow with some colours at end of the flow. Is my MSGEQ7 bad cuz I used a 1 nF accidentally instead of 10 nF at the power connection to it.
Note I tested the audio going to the it using a small speaker so audio is getting to the MSGQ7
Thanks!
Answer 3 years ago
I found out it doesn't work with MSGEQ7 1902 chips. I bought the 1902. So I'm going to get another one and see. Thanks!
Question 3 years ago
Hi @PhilKey I'm very new to this. I am a computer systems student. I did some soldering work but when it comes to circuit I have very little knowledge.
I want to have this pattern execute on 2 2m parallel strips of 60 LED/m. SO 220 in total and would also like to have enough power to add more led in the future. I will be using a 12 volts 8aH battery that will be continuously charged at 14 volts. So might actually get 14 volts to this led controller. What changes would I have to make to this instructable to achieve this?
Please and thank you!
Answer 3 years ago
So the WS2812B LED strips and the Arduino Nano need 5V, so you would have to use a DC Step Down Converter to convert your 14V to 5V
For this you could simply use a LM2596, like this one:
https://aliexpress.com/item/890333309.html
Reply 3 years ago
Thank you so much. I ordered the rgb strips. I'm going to order the rest of it and hopefully get it working!
3 years ago
Hey Phil,
thanks for your Work.
The Msgeq7 doesnt work for me, how can I use the Fft in combination with the Led stripe?
Reply 3 years ago
Hi there,
I just recently started working on an updated version without using the MSGEQ7 and instead using the FFT sketch, but it is not finished yet.
I will update this instructable when I have the time to finish it
Reply 3 years ago
One thing i wanted you to say. The MSGEQ7 only divides the signal into 7 bands, not 8. This is why you have to skip Band 3 in the code.
3 years ago
Hi @PhilKey
Thanks for your sharing
I only have one 3.5 audio out
Could i split it by a circuit. 1 to MSGEQ7 and 1 to Amplifier ?
Reply 3 years ago
Yeah of course, you could just have 3.5 Audio Jacks, all are connected, 1 is the Input and the other 2 are parallel Outputs, so you can connect 1 to the MSGEQ and 1 to an Amplifier
Question 3 years ago on Introduction
CAN I DO IT WITH 12V RGB STRIP
Answer 3 years ago
Why not?
Reply 3 years ago
thnkx
3 years ago
Hi PhilKey, can you please elaborate on the circuit connection of the msgeq7.
In your diagram I can see pins 3, 4 & 7 connect to the Arduino.
Pin 5 connects to the audio jack. Now is that to both right and left channels together?
Then I couldn't understand pins 1, 2, 6 & 8. Can you please explain what each one connects to.
Thank you so much for this amazing project.
Reply 3 years ago
Pin 5 is connected to a single Audio Channel (Either left/right, not much of a difference). You simply leave the other channel not connected to anything.
Now Pins 1,2,6,8 are not connected to the Arduino.
Pin 1 and 2 are connected to each other over a non-polarized (e.g Ceramic Capacitor with 100 nF), with Pin 1 also being connected to VCC (+) of the power supply, and Pin 2 to Ground (-) of the power supply.
Pin 6 is simply conencted over a 100nF (non polarized) capacitor to Ground(-)
Pin 8 connects to VCC(+) over a 200k Ohm Resistor and over a 33pF (non polarized) Capacitor to Ground(-).
3 years ago
hello
can you help me, i can't understand the theme with msgeq7.
Please help me.
3 years ago
could this be used with arduino Uno or Omega?