How to Make LEDs Flash to Music With an Arduino




This is a guide to make an LED flashing circuit that "beats" to an mp3 file on your computer, which can add an awesome effect to any sound-related device, or even your room (if you extend the concept with LED drivers or plenty of resistors/transistors).

The LED flashing circuit makes use of the Minim audio library and the Arduino program Processing to analyze sound, producing a response based on a snare drum hit, a bass drum hit, and a hi-hat hit from the percussion of the audio file.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Parts/Tools Needed

Here is what you'll need to make the LED beat flashing circuit:

1. An Arduino microcontroller board. There are many versions of the Arduino, but I would recommend the Arduino Duemilanove. You can buy one online for around $20.
2. Three LEDs (different colors preferred, so you can see the difference in beats easier - I used a red, yellow, and green LED)
3. Three resistors (depending on your LEDs, the resistor value will be different - check the ratings on the LEDs to see what resistance corresponds to their maximum brightness, without burning them out)
4. A solderless breadboard
5. Some wire, to use as leads from the Arduino to the LEDs/resistors on the breadboard
6. A computer
7. A USB cable (A to B)

1. Arduino Software Environment
2. Processing Software Environment
3. The "arduino" library for Processing
4. The BeatWrite / BeatListener code from the minim JavaSound library examples

Download links for the software will follow in Step 3.

Step 2: Build the Circuit on the Breadboard

In order to have the Arduino access the LEDs, you have to build a small circuit on a solderless breadboard. The breadboard has two parts: the inner rails (which run width-wise) and the outer rails (which run length-wise). The rails are electrically connected along their lines, so you can connect components without actually soldering them together. Here is how to make our simple circuit:

1. Run a wire from the digital GND port of the Arduino to the negative outer rail of the breadboard, as shown in image 1.
2. Place your three resistors (I used 1kilo-ohm resistors for this example, which matched my LEDs well enough) in an evenly-spaced fashion on the inner rails of the breadboard. Note that on a breadboard, a line runs length-wise, halfway down the middle. This separates the left inner rails from the right inner rails, so you can connect more components. Position the resistors so that they bridge the gap between the inner rails, as shown in image 2.
3. Place the LEDs right next to the right side of the resistors, with the anode (the longer end) in the slot right next to the resistor, and the cathode (the shorter end) into the slot that is offset to the resistors by 1 slot, as shown in image 3 (see image 4 to see the difference between an anode and a cathode).
4. Run wires from the cathode rail of the LEDs to the ground outer rail, as shown in image 5.
5. Run wires from the anode side of the resistors to digital pins 12, 8, and 2 on the Arduino to complete the circuit, as shown in image 6 and 7.

Now that we have our circuit made, it's on to the programming.

Step 3: Program Your Arduino

Programming the Arduino is pretty simple. Through a couple of small programs, your simple LED circuit will be dancing to the beat in no time.

1. Connect the Arduino to your computer with your A to B USB cable (your computer should install its driver automatically) - see image 1.
2. Download the Arduino Software Environment from here and extract it to a folder (no installation required, just keep the folder in a safe place).
3. Download the Processing Software Environment from here and extract it to a folder near your Arduino SE folder.
4. Download the Arduino library for Processing from here, and copy it into your Processing/libraries folder.
5. Run the arduino.exe program in your Arduino SE folder.
6. Go to File -> Examples -> Firmata -> StandardFirmata, and press the Upload button on the Arduino SE (see image 2).
7. Wait a few seconds, until your RX/TX LEDs on your Arduino stop blinking (which means the Firmata firmware is installed).
8. Download and unzip the attached folder of code below (
9. Copy an .mp3 file into the "data" folder of the unzipped BeatWrite folder.
10. Open Processing (processing.exe), then open the BeatWrite.pde file in the BeatWrite folder.
11. Edit the line of code "song = minim.loadFile("freebird.mp3", 2048);". Instead of using "freebird.mp3", use the filename of your mp3.
12. Hit the Run button on the top-left (see image 3).

Sit back, and enjoy the light show!

Step 4: How It Works / Customizing the Script

The reason this program works is due to the minim JavaSound library. This fancy library comes with Processing, and can do plenty of cool things with analyzing audio signals. In our case, it uses the fast fourier transform of the audio signal from the mp3 to analyze certain frequencies, and lights an LED if certain ranges of frequencies go above the allotted "sensitivity" value. In order to change this sensitivity value, all you need to do is change the "beat.setSensitivity(100);" line of code in the BeatWrite program. Also, as I said before, you can definitely extend this concept to many LEDs on a large scale. This is just a small-scale example of the potential for this great library. Also, if you know more about your mp3 than just generic hi-hat, snare, and bass drum hits, you can use the isRange(int low, int high, int threshold) method to beat the circuit to other patterns in your music. The sky is the limit in terms of audio processing with Minim and BeatDetect.

Many thanks to the Minim team for providing a BeatDetect manual with plenty of examples. This LED tutorial is a hardware extension of this software example.

Step 5: How It Should Look

Here is a video of when I first made the BeatWrite circuit (it looks a little different than the one we're building, but the concept is the same).

Have fun with your new Arduino BeatDetect circuit!

12 People Made This Project!


  • Made with Math Contest

    Made with Math Contest
  • Multi-Discipline Contest

    Multi-Discipline Contest
  • Robotics Contest

    Robotics Contest

257 Discussions


Question 27 days ago on Introduction

Hey, I'd rly like to know how many LEDs you can connect to it? Like if I want like 10 LEDs blink just on bass-made sound, is that possible to make it ? :D

Btw, you did such a nice job there :)


Question 1 year ago

I made it!! Super awesome project. Was wondering how this could work to trigger relay signals. I have made few projects with relays and understand how they work but it seems this output signal is not the same as a HIGH/LOW that that relays need. Is it possible to do with this project?


1 year ago

Hi I am new to Arduino and just trying to learn the code, I know a little Bash scripting.

My question - is it possible to modify the code to create a loop to play through a series

Of mp3 files ( create a sort of play list).


Question 1 year ago

I fixed the first problem but now it is saying that cc doesnt exist. Any help to fix this probelm will be appreciated.

1 answer

Answer 1 year ago

Download processing-arduino zip from >this< link, and extract the 'arduino' folder into Processing sketchbook folder (you can find its location on File>Preferences).


Question 1 year ago

When I run the other program and press go, it says that ddf is missing and that a libray might be missing. How would I solve this problem?


Tip 1 year ago

1. For missing libraries go to Processing IDE > Sketch > Import library > Add Library and install Minim

2. In "arduino = new Arduino(this, Arduino.list()[1], 57600);" replace 1 with 0

3. If LEDs still don't blink, reverse/flip the LEDs around. Worked for me!


Question 1 year ago

Hi, ive been trying to upload the standard firmata, but ive already run into a problem, here is the error code:

c:\program files (x86)\arduino\hardware\tools\avr\bin\../lib/gcc/avr/4.9.2/../../../../avr/bin/ar.exe: unable to rename 'core\core.a'; reason: File exists

exit status 1

Error compiling for board Arduino/Genuino Uno.

How can I fix this?


Tip 1 year ago

On beat write make sure you have the correct pin numbers for the arduino and you have to change the arduino = new Arduino(this, Arduino.list()[1], 57600) to arduino = new Arduino(this, "The Port You Are Using", 57600). You find the port you are using in the arduino SE by clicking Tools->Get Port Info. I don't know if this is what everyone needs to do but I had to change the digital.write in BeatWrite to analog.write.


1 year ago

I'm having an issue when pressing "run" on the beatWrite as it gives the following message:

No library found for dff.minim

No library found for dff.minim.analysis

No library found for cc.arduino

Libraries must be installed in a folder named 'libraries' inside the sketchbook folder (see the Preferences window).

I have downloaded the latest version of Minim and have tried to move the location of it to the libraries folder in the sketchbook but it still gives the same error message.

Can anyone tell me how to fix this?

4 replies

Reply 1 year ago

I am having the exact same problem. Any help would be appreciated :(


Reply 1 year ago

On the Processing IDE go to Sketch -> import library and search for Minim and install the Minim audio library. Should get rid of your problem.


Reply 1 year ago

Make sure you're importing the right library. What library are you actually importing and what error are you getting now?


4 years ago on Step 3

If someone could help me I would be so unbelievably grateful. I did all the steps, but I get an error that says, "Cannot find a class or type named BeatListener"

Please can someone help me. On one of the pictures ^^^ There are two tabs: BeatWrite and BeatListener. I only have BeatWrite. Can someone please help me!!!

1 reply

Reply 1 year ago

Did you solve it in the last 3 Years? :D I have the same problem now xD


Question 1 year ago on Step 3

when i hit the run button nothing happen


Reply 1 year ago

Open Arudino and when you download the Firmata as it states to do in this tutorial, notice what port the Arduino is hooked to (COM8, for example). Then you need to edit the line of code in the processing software to match which port your Arduino software states. Hope this helps!