Introduction: 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
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
Attachments
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!
- diesel_travis made it!
- radman5240 made it!
- diesel_travis made it!
- CaitlinR12 made it!
See 3 More
103 Comments
Question 11 months ago on Step 3
Can I use three of the N-Channel MOSFET 60V with 30A instead of 50A?
I am planning to use https://www.sparkfun.com/products/10213
It shouldn't make a difference since my LED strip is consuming less than 30A, right?
Answer 11 months ago
30A seems to be the upper bound which my 60V 30A N-Channel MOSFET will work on and I guess since my LED strip consumes less than 30A per color channel it will be sufficient.
Also, I guess you would need a massive LED strip to consume 90A+ (30A * 3) and an even bigger one to reach the limit of the 50A one (150A+), so no need for the 50A version.
Question 11 months ago on Introduction
Do I need a 220k resistor or a 22k resistor?
On the wiring image it says 22k but the shopping list says 220k.
Answer 11 months ago
I took a look at the MSGEQ7 guide linked (http://nuewire.com/info-archive/msgeq7-by-j-skoba/) and he is using a 200k resistor so I am guessing 220k is sufficient.
After also looking at the datasheet at page 4 (which I should've done before asking a question) I have concluded that you should indeed use a 200k resistor.
I will use a 220k resistor since I don't have a 200k. davidwangdw used a 220k resistor so I am guessing it will work fine.
Link to the datasheet: https://www.sparkfun.com/datasheets/Components/General/MSGEQ7.pdf
3 years ago
I had one problem with this project, my iPhone 7 does not have an audio jack and yes I could use the adapter but bluetooth is preferable. So I found this bluetooth audio receiver on amazon and it worked great for me:
https://www.amazon.com/Mpow-Bluetooth-Receiver-Streaming-Hands-free/dp/B008AGQMQC/ref=sr_1_4?ie=UTF8&qid=1514999324&sr=8-4&keywords=bluetooth+audio+receiver
Reply 2 years ago
I tried this, but the blue light it always on with or without music. Did you find a way around this?
Reply 1 year ago
Sorry for the 7 month late responce but I never had that problem,
Question 2 years 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?
Question 2 years 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.
Question 2 years 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
3 years ago
Step #2 pictures shows a 22k resister instead of the needed 200k resister.
3 years ago
Can you please give me your MOSFET number you used in this project
Reply 3 years ago
This projects MOSFET number was RFP50N06
3 years 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.
5 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.
Reply 3 years ago
thanks for your comments! I will need to fix the tutorial to reflect this
Reply 3 years 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
Reply 4 years 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.
Reply 4 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?
Reply 4 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