Blinking LEDs to the Frequency of Music

Introduction: Blinking LEDs to the Frequency of Music

About: Hi my name is David. I like playing piano, taking pictures, and folding origami.

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

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

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!

7 People Made This Project!

Recommendations

  • Creative Misuse Contest

    Creative Misuse Contest
  • Fix It! Contest

    Fix It! Contest
  • Metalworking Contest

    Metalworking Contest

95 Discussions

This was so easy to follow, I made this in one day! It was my very first Arduino project I have ever done so I am extremely thankful there are links for all of the parts. If you are a beginner like me, here are a couple tips:

1. I got an audio jack from Tayda and the graphic equalizer from oddwires because they had $3 shipping as opposed to sparkfun's $7 shipping. http://www.oddwires.com/msgeq7-msi-graphic-equaliz...

2. Here is the updated Fritzing file: http://fritzing.org/projects/blinking-leds-to-freq...

3. Resistors are not directional and the MOSFET transistors get hot so have a desk fan or something nearby.

4. The updated wiring diagram and software is perfect so if something is wrong, maybe look at your audio jack. If you look at this data sheet, A is ground and B or E will provide your signal. If you hook up to C or D, you will get NOTHING. https://www.taydaelectronics.com/datasheets/A-069....

5. The cheap LED light strip does not have a plastic cover so the individual LEDs are prominent making the light pixilated/choppy. If you want the light to blend more evenly, get a covered, waterproof strip.

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

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

1 reply

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.

IMG_1069.JPGIMG_1070.JPG

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.

10 replies

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

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

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.

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?

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

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

thanks Isaack19

Here is my Fritzing project update on this.

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

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!

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?

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.

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

1 reply

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

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?