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

  • First Time Author

    First Time Author
  • Toys Contest

    Toys Contest
  • Big and Small Contest

    Big and Small Contest

99 Discussions

0
None
gamaliux

Question 23 days ago on Introduction

Hello, I have a question. If I don't use audio jack, but I would go straight to a speaker wires? Whould it work?

0
None
Maria CamilaC2

Question 3 months ago

My led stripe doesn't turn on at all, and i'm getting values around 239 - 250 on the serial monitor. Anyone knows how to make it work? I've double checked all connections.

0
None
MircoJ

Question 3 months ago

I have a problem with this. I only got the values "0 0 0 0 0 0 0". I checked the raw input and it was always something about 608. I also tried if my audio jack is working, and yes, it is :P

0
None
bchou123AndrewA131

Reply 3 months ago

I tried this, but the blue light it always on with or without music. Did you find a way around this?

0
None
bchou123

Tip 4 months ago

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.

0
None
supernoodle2014

1 year ago

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

0
None
Yusuf BeenH

1 year ago

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

1 reply
0
None
waxerman1

1 year ago

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
0
None
Isaack19

2 years ago

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.

9 replies
0
None
davidwangdwIsaack19

Reply 1 year ago

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

0
None
MichaelK545davidwangdw

Reply 1 year ago

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

0
None
Jesper.Isaack19

Reply 1 year ago

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.

0
None
CharanK3Isaack19

Reply 2 years ago

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?

0
None
Isaack19CharanK3

Reply 2 years ago

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

0
None
CharanK3Isaack19

Reply 2 years ago

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

thanks Isaack19

0
None
Isaack19Isaack19

Reply 2 years ago

Here is my Fritzing project update on this.

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

0
None
ReedJ1Isaack19

Reply 2 years ago

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!

0
None
ReedJ1Isaack19

Reply 2 years ago

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?