Introduction: Blinking LEDs to the Frequency of Music

Picture of Blinking LEDs to the Frequency of Music

Hey guys, in this tutorial I will be showing you exactly how I set up my Arduino board to take a standard audio input and then flash a set of LEDs based on the frequency of the music playing.

Here's a short video of it in action:

YouTube

Step 1: Materials Needed

Picture of Materials Needed

Here's a list of what materials you need and where to get them:

Note: I'm a big fan of Tayda Electronics, as their materials are very cheap and they usually post 15% off discounts on their Facebook Page.

1 x Breadboard
1 x 12V 5A power supply
note: this depends on how long you want your LED strip to be, I find that 5A is plenty for 5 meters, it could probably even handle more since you'll be fading between colors instead of having everything on maximum. Here's a look link to how I figured out the current draw: link
1 x LED strip (waterproof and nice 1M long strip here, super cheap and ok-quality 5M here)
1 x Audio Jack
3 x 10k resistors
1 x 220k resistor
1 x 33pf ceramic capacitor
2 x 100nf ceramic capacitor
1 x 10nf ceramic capacitor
1 x Arduino (I used a sparkfun-branded RedBoard, but an Arduino Uno would work fine
1 x 3.5mm audio cable
1 x MSGEQ7
3 x N-channel MOSFET Transistors
Many x male to male jumper cables

1 x speakers

Computer with Arduino Software Installed

Step 2: Setting Up the Circuit

Picture of Setting Up the Circuit

Look at the attached picture for details. I used a combination of:

The RGB LED strip tutorial from Adafruit

The MSGEQ7 tutorial from skoba

I also attached my Fritzing file if you want to look at it.

EDIT: I made a small error in the Fritzing file. Please see the following comment (thank you Isaack19 for the clarification)

IMPORTANT: MAKE SURE PORT 2 (and any other ports that need to be grounded) ON YOUR MSGEQ7 IS NOT GROUNDED TO THE SAME GROUND AS YOUR MOSFETS. The Fritzing file shows the MSGEQ7 sharing ground with the MOSFET transistors. I was about to return my MSGEQ7 back from where I got it because of this. I almost gave up, but then I noticed in the serial monitor that when the 12v 5a power supply is plugged into the Arduino, the last two of seven frequencies spike up (it went from 0 0 0 0 0 4 19 to 0 0 0 0 0 8 39. Notice the last two numbers were also spiking up without the power supply plugged in.) Anyways, after grounding the MSGQE7 and the MOSFET transistors to separate grounds, all seven frequencies were at 0. I just wanted to share this with you because I saw some other people having problems.

Step 3: Setting Up the Script

I attached my script, let me know if you have any trouble with it. It's pretty straight-forward. Upload it to your Arduino and you should be good to go!

Here's also a pastebin of my code:

http://pastebin.com/wsHFADWe

Step 4: Final Steps

So what I ended up doing is getting a headphone splitter and then having one end go into an iPod/mp3 player, one end going to a set of speakers and then one end going into the audio jack on the arduino circuit. This way, the arduino circuit could get the audio input to change the lights, and the speaker could play the music at the same time. Hook everything up right, and you should be all set. Comment if you have any questions and/or suggestions!

Thanks for reading!

Comments

supernoodle2014 (author)2017-12-01

Step #2 pictures shows a 22k resister instead of the needed 200k resister.

Yusuf BeenH (author)2017-06-30

Can you please give me your MOSFET number you used in this project

waxerman1 (author)Yusuf BeenH2017-07-04

This projects MOSFET number was RFP50N06

waxerman1 (author)2017-06-28

I would first of all like to say thank you for this project that I can spend some free time on this summer.

I have 4 hardware problems I was hoping I could get help with.

1: My cables from my LED strip don't want to stay in the breadboard, is there a way I can get them to stick in?

2: My Audio Jack doesn't have a way for the jumper cables to connect, although it does have prongs. Either that or I'm looking at it wrong. Any suggestions? (Pictures included)

3: My MSGEQ7 is 2 slots smaller than the one shown in the picture, what do I need to do because of this? (Picture included)

4: And finally does it matter what colors I plug in where in comparison to the picture? It shows I need 5 red cables but I only have 4.

Isaack19 (author)2016-01-16

Thank you so much David W. for this awesome project! I got mine to work perfectly after some tweaking (read below, will probably help).

IMPORTANT: MAKE SURE PORT 2 (and any other ports that need to be grounded) ON YOUR MSGEQ7 IS NOT GROUNDED TO THE SAME GROUND AS YOUR MOSFETS. The Fritzing file shows the MSGEQ7 sharing ground with the MOSFET transistors. I was about to return my MSGEQ7 back from where I got it because of this. I almost gave up, but then I noticed in the serial monitor that when the 12v 5a power supply is plugged into the Arduino, the last two of seven frequencies spike up (it went from 0 0 0 0 0 4 19 to 0 0 0 0 0 8 39. Notice the last two numbers were also spiking up without the power supply plugged in.) Anyways, after grounding the MSGQE7 and the MOSFET transistors to separate grounds, all seven frequencies were at 0. I just wanted to share this with you because I saw some other people having problems.

So after fixing that, my project ran flawlessly. Thank you again, David.

I used an Arduino R3 for this project if you're wondering. It cost me a total of about $35 (including shipping) for everything except the Arduino, jumper cables, and breadboard.

davidwangdw (author)Isaack192017-04-04

thanks for your comments! I will need to fix the tutorial to reflect this

MichaelK545 (author)davidwangdw2017-04-27

How would I seperate the grounds, are have you already updated the tutorial? Also I want to add a bluetooth module because I have an app that can control the colors of the led and have a code that I can use. If you could please email me @ Michaelkintner35@gmail.com, because I have a few more questions haha

Jesper. (author)Isaack192016-12-14

Hey,

I seperated the grounds as you said in your tip but still I still get that 2 out of 7 bands give a value.

"0 0 0 12 64 0 0

0 0 0 12 64 0 0

0 0 0 12 57 0 0 "

I have seperated the grounds as you said. MOSFET and MSGEQ7.

I've have looked for hours for a solution, if you might know something please help me out if you are willing to.

Thanks you.

CharanK3 (author)Isaack192016-06-08

Hey Thanks for tip. I tried working according to your fritzing page .I have a 161-3508-E type audio fack which are the pins do i need to connect?

Isaack19 (author)CharanK32016-06-08

Not sure. I just ordered the audiojack and it worked fine.
http://www.taydaelectronics.com/hardware/3-5mm-plugs-jacks/3-5mm-stereo-enclosed-socket-chassis-jack.html

CharanK3 (author)Isaack192016-06-09

Had done a grounding mistake its finally working!!!!!!!!!!!

thanks Isaack19

Isaack19 (author)Isaack192016-01-28

Here is my Fritzing project update on this.

http://fritzing.org/projects/blinking-leds-to-frequency-of-music

ReedJ1 (author)Isaack192016-02-01

Awesome. After looking at my Redboard again, i did find the 3rd ground pin so i should be ready to go. Thanks for the help!

ReedJ1 (author)Isaack192016-01-28

Thanks for the heads up, i'm about to start this project up as well. I do have a quick question concerning the two separate grounds. On both the Arduino Redboard and the Arduino R3 there are two ports that can be used for ground. Are you saying that i should be using one of those ports for the MSGEQ7 and the other port for the MOSFET? If so, will it matter which port i use to ground the Audio Jack?

Isaack19 (author)ReedJ12016-01-28

The Arduino R3 should have 3 grounds (at least mine does). I attached the ground for the audio jack to one of the three ground pins on the arduino, the MSGEQ7 to another one of the three ground pins, and the MOSFET transistors to the last pin. If you do have only two pins, then let the MSGEQ7 have its ground pin on the arduino and the MOSFET transistors have their own ground on the arduino. So that leaves you with no pins and the audio jack not grounded. So you could try experimenting by putting the audio jack ground to the same ground as the MOSFETS and if that doesn't work then try grounding it to the MSGEQ7 ground. Hope this made sense. I'm working on a fritzing file and will put it on here when done.

roukinpouliot (author)2017-03-30

What if i want 10 m? What will be the modifications? Whitch led sould i use?

it's the same instructions, you'll just need to replace the LED strip in the tutorial with your own LED strip

ZacharyB74 (author)2017-02-07

I don't think my lights are receiving power from the unregulated voltage pin. I don't know if this could be a code issue or a difference with my arduino?

ovswscrum (author)2016-12-31

Thank you for taking the time to post this tutorial.

davidwangdw (author)ovswscrum2017-01-01

Thanks for the comment and taking the time to read it!

nik3baller09 (author)2016-11-20

Hi, I'm experiencing an issue where my LED strip powers on, but does not pulse
along with the music. I read the comments below and one adjustment I made to my circuit is grounding my MSGEQ7 separate of my MOSFET transistors, but that did not do the trick. Did anyone else experience this problem? If so, did you have to replace any parts or any adjustments to the code? Any solutions or advice would appreciated
greatly!

tycon4 (author)2016-11-09

Is there a way to make this without 4 connections to the LED? My strip only has 3, power + -, and data. If there is how would I do that? This tutorial is exactly what I am looking for.

TechFox (author)2016-11-07

As a new learner, I was wondering how the different placement of the resistors for the LED strip here works in comparison to the Adafruit tutorial?

diesel_travis (author)2016-10-28

Has anyone moved this from the breadboard to something more permanent?

diesel_travis made it! (author)diesel_travis2016-10-29

Well here's my attempt at transferring from my breadboard to 2 separate perf boards...

radman5240 (author)diesel_travis2016-11-01

Interesting take on it. How easy would it be to mount those other boards though? I like how compact you were able to get the EQ chip components on the board. You should check out my comment, I moved it over to a PCB board too.

diesel_travis (author)radman52402016-11-02

It would be difficult to mount them on anything, there isn't much room left. I may just wrap them in tape just to keep them from accidentally shorting. I have to tweak the program though, it was really giving me a headache when I was using them on Halloween.

AroZoirI (author)2016-10-26

Hi, i try to make this project but i have some issues.

(sorry for my english i'm french :) )

So when i look up the monitor i see something like this :
10 27 11 11 11 11 11
10 11 8 27 11 11 11
11 11 11 11 8 27 12
10 11 11 11 11 11 17

What ever the audio jack is on or off.

And also the light don't turn on :/

If some one can help me thanks :)

AroZoirI (author)AroZoirI2016-10-26

Here the circuit (picture) :

http://www.noelshack.com/2016-43-1477481042-img-20161026-131513.jpg

Baaayer (author)AroZoirI2016-10-26

I think you're missing the power supply for the RGB strip? You need a 12V---5.0 A power supply

AroZoirI (author)Baaayer2016-10-26

I will buy one on amazon and try but, is it normal that i don't see 0 0 0 0 0 0 0 when i don't plug the jack ? :/

radman5240 made it! (author)2016-09-29

I made it on a breadboard first, wiring it a few different ways to see if it reduced noise at all. In the end, i found that it didn't matter too much. I did find, however, that the issue of noise in the lights did get slightly worse once i soldered it to the PCB. Not noticeable while music plays, but you can notice when music is quiet or completely off, which bugs me. I've played with the filter in the code and it doesn't seem to help all that much. Either way, I'm glad with how it turned out and plan on making a light diffusion box in order to use it as stage lighting.

Heres some videos of it working

ReedJ1 (author)2016-08-31

So i finished up this project months ago, but out of the blue my circuit is no longer working. The circuit is powering up the LED strip, but remains on a a white color. The chip that i am using is in the same condition as when i bought it. I have noticed that the transistors get very hot when the power supply is added to the circuit. I have tried replacing the transistors with new ones and i they still begin to heat up. Any help would be awesome.

vfanelli (author)2016-01-11

I am having a problem, the leds arent nearly as bright as they are supposed to be, Its mostly green, and they dont pulse to the frequency of the music. If you know the solution to these problems, please let me know.

newport95 (author)vfanelli2016-08-13

Hi vfanelli, did you have any luck fixing this problem? I'm having the same one you described.

ConorC8 (author)2016-07-01

Would it work if I directly replaced the audio jack with a sound sensor, or would i need to alter the code?

davidwangdw (author)ConorC82016-07-04

I think you might have to alter the code. The code is based on direct physical reaction from the audio jack, so i'm guessing the values you'll get with a sound sensor is different, unless you can calibrate it to match an audio jack. i'd try and see the output from the sound sensor, see the max and mins, and try to base it off that

CharanK3 (author)2016-06-09

Thanks for the awesome project David W

nzappia (author)2016-05-24

I'm trying to make this project, I have setup all the components and connected my phone to the audio Jack, it works just, but it's very faint and only purple flashes

JoshK65 (author)2016-05-17

Hey guys, fairly new to these kinda things and had a question. I was going to make these with some RGB strips i had lying around, but the strips only have 1 input. Can I still use these or do i have to order new strips. If I can then how so? Thanks in advance!

ZachD19 (author)2016-04-20

Will this work with a 30pf instead of a 33pf capacitor?

BrightSol (author)2015-03-26

How can I modify this to work with a 5v 10a power supply so I can use Neopixels?

DavidW41 (author)BrightSol2016-04-16

Like lights 01 23 said, should be easy. Add your leds in place of the strip and you can change the code to add more channels

lights0123 (author)BrightSol2015-05-10

You don't need to modify anything, except for using a 5V LED.

ZachD19 (author)lights01232016-04-14

How can i modify this to use just 5 RGB LEDS, not LED light strip

LaurenceW2 (author)2016-02-12

Hi Guys,

I've spent hours on this and just can't figure it out. I've checked and rechecked. Re-configured the grounds, checked all the codes, but its not happening. I bought 2 MSGEQ7 chips from Sparkfun, but i think these are the problem. All i get on the serial is 0000000 and nothing i do changes this. As a last resort, i turned the chip around and got a bunch of random numbers. the light strip has all three colors on, very faint.

Other than buying more MSGQ7 chips, I'm stuck! Any troubleshooting tips would be great. I've included a couple of pictures of the setup, in case I've done something really dumb!

diesel_travis (author)LaurenceW22016-04-04

are your resistors and caps the right values?

diesel_travis made it! (author)2016-04-04

I am going to tweak it a bit because I'm getting a lot of green, but it's mostly working great:

https://vine.co/v/ijnviqtl3UE

https://vine.co/v/ijnOIA0rp7v

https://vine.co/v/ijnipK3EVqq

JamesH265 (author)2016-03-06

Hey all, stumbled upon this project when I was thinking of building a fully RGB color/light organ and this solved all my problems. How would I go about wiring/programming this so that it does outputs for both the right and left channels of the audio input, not just one? I know I'd need pretty much double the hardware, but aside from getting 2 arduinos, can this be done with just one? (bit of a noob here, so I apologize)

XavierA21 (author)2016-03-01

Hey there... I've been wondering if i can add the power supply cord and the ir blaster to change colors.. i mean, having this arduino project and the power and controls that come with the led strip working together... if so, how?

About This Instructable

102,049views

222favorites

License:

Bio: Hi my name is David. I like playing piano, taking pictures, and folding origami.
More by davidwangdw:Blinking LEDs to the Frequency of Music
Add instructable to: