Introduction: How to Make LEDs Flash to Music With an Arduino

Picture of 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.

Step 1: Parts/Tools Needed

Picture of 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

Picture of 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

Picture of 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!


AadityaR9 (author)2017-09-08


hoss1589 (author)2017-08-30

I've fixed all the problems except now it says:

==== JavaSound Minim Error ====

==== Don't know the ID3 code GRP1

hoss1589 (author)2017-08-30

Can someone please help me? I have done everyhing like he said but yet when i go to processing and open beat write it said: Error opening serial port COM4: port busy. I tried changing: arduino = new Arduino(this, Arduino.list()[1], 57600); to: arduino = new Arduino(this, Arduino.list()[0], 57600);

and this time it pulled up everything and didn't have any errors but when it opens up the beat write program it just goes to a white screen and doesn't respond. I need Help ASAP!

vaibhavm41 (author)2017-08-05

i wanted to change the frequencies at which the LEDs would blink .how can i do so??

Tomc339 made it! (author)2017-07-02

This was fun but I couldn't configure the detection of the snare, kick and hat correctly so it mostly just appears that the LEDs fire randomly.

NotWillFerrell (author)2017-06-25


so i solved my previous problem by going to sketch/ add library and searching for minim and installing it but now it has another error it says: "ArrayIndexOutOfBoundsException: 1" and it highlights line 35 which reads "arduino = new Arduino(this, Arduino.list()[1], 57600);" can anyone help me pls

NotWillFerrell (author)2017-06-25

okay i was successful until the point where i had to run the beatwire pde code it did not upload it says: "The package "ddf" does not exist, you might be missing a library." can anyone help me

ASJYO (author)2017-04-30

Hello, me and my classmates are planning to make a miniature night club for our project with arduino. the concept is to make the led lights blink depending on the beat of the music that we will be playing thru a Bluetooth speaker. Is our idea even possible?

EmilyM178 (author)2017-03-07

Hi all, hoping for some insight here.

All connections appear to be correct on the Arduino (I'm using an Arduino Uno) and my mp3 has been copied into by BeatWrite Data folder, and the minim library is installed, but still can't troubleshoot these errors. Any thoughts?

EmilyM178 (author)EmilyM1782017-03-07

Errors Read as:

==== JavaSound Minim Error ====

==== 08 Hunger Of The Pine.mp3

=== Minim Error ===

=== Couldn't load the file 08 Hunger Of The Pine.mp3

SiDawg (author)EmilyM1782017-04-09

The thing i'd focus on is "FileNotFound"... Did you do these steps below? Also: I'd try getting rid of spaces in your file name... i.e. rename your file without spaces, and then change your code to use that new "non space" name... Some times things don't like spaces in file names

"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."

Arafe ZawadS (author)EmilyM1782017-03-09

try the following

Isaack19Replya year ago

Works great! I used an Arduino R3 and it works fine. In processing, if you are missing libraries, go to "Sketch > Import Library > Add Library" and add "Arduino (Firmata)" and "Minim". Also changing

"arduino = new Arduino(this, Arduino.list()[1], 57600);"


"arduino = new Arduino(this, Arduino.list()[0], 57600);"

made it work.

KevinN109 (author)2016-11-20

I'm wanting to build a custom electric guitar with an Arduino brain inside the body, and led's on the outside that will light up when certain frequencies are passed to the output jack. Is there a way to route those frequencies into the Arduino instead of an mp3 file to light the lights?

Thibautw1 (author)KevinN1092017-02-28

DanielT252 (author)2016-10-19

guys I get and error that says

=== Minim Error ===

=== Couldn't load the file crazy bass mastered

Could not run the sketch (Target VM failed to initialize).

For more information, read revisions.txt and Help ? Troubleshooting.

why is it saying that?

Thibautw1 (author)DanielT2522017-02-28

Have you installed every library needed?

mohitk61 (author)DanielT2522016-11-14

you have to put file extension with file name

ThéoC17 (author)mohitk612016-12-24

hello, can you give me an exemple ? Because I have this problem :/

bhate (author)ThéoC172016-12-24

go to sketch>add file , it finally worked!

Tunebug (author)2016-12-26

Hi All

Im very new to this but love this video and really want to make this work. I keep getting the following error message:

expecting SEMI, found 'song'

On this line:

song = minim.loadFile("123.mp3", 2048);

Can someone help please? Im sure this is probably a quick fix but im stumped!


Thibautw1 (author)Tunebug2017-02-28

Copy the mp3 file into the data folder (locate your BeatWrite folder=>data), then copy the name from the song make sure the .mp3 is copied too and replace it with the: song = minim.loadFile("123.mp3", 2048);, also make sure the *song*.mp3 is between the " ".

Isaack19 (author)2015-12-28

Works great! I used an Arduino R3 and it works fine. In processing, if you are missing libraries, go to "Sketch > Import Library > Add Library" and add "Arduino (Firmata)" and "Minim". Also changing

"arduino = new Arduino(this, Arduino.list()[1], 57600);"


"arduino = new Arduino(this, Arduino.list()[0], 57600);"

made it work.

Arafe ZawadS (author)Isaack192017-02-27

thank you :D

NuruddinE (author)Isaack192016-12-03

thank u!! It works fine now :D

DanielD347 (author)Isaack192016-07-26

Thank you!!

HoàN25 (author)2017-02-20

Is it possible to replace a rgb led strip for single led?

omkar2309 (author)2017-01-22

Is it possible to use the same code and instead of using it to light up single LEDs, we can fire up multiple LEDs like in a series or as a structure? just a basic design to make all LEDs light up for different "beats".

TianL4 (author)2016-04-25

would it be possible to make a cube of LEDs 3 by 4 on each side?

omkar2309 (author)TianL42017-01-22

I am trying to get the different layers to flash individually for each output, using the basic 3x3x3 LEDCube circuit, probably harder than it looks :/

one question: would assigning three pins as output for kick/snare/hit have the same effect as having one output, considering a 3x3x3 cube requires 9 inputs to each column of LEDs and three more for arranging the transistors to each planar layer of LEDs?

I've got it running fine with three LEDs

alysa.ingie (author)2017-01-15

Hi! thanks for this tutorial, very interesting and there's not much on this. I just have a couple of questions! First what do kickSize/snareSize/hatSize do? and how do I use inRange? what do the values in inRange represent?


Jestin j (author)2016-12-31

guys am new here... i liked dis video. but i want to join a series of led lights.... lik dis one.. pls help me

EdwinE5 (author)2015-10-23

Hi, I just did everything that's told on the instructions, I built the circuit, BeatWrite runs without errors but leds won't light up. Can anyone help me?

TechnoTony (author)EdwinE52016-02-14

You may need to change the 0 in this line to the com port number your Arduino is using:

"arduino = new Arduino(this, Arduino.list()[0], 57600);"

mohitk61 (author)TechnoTony2016-11-14

No you have to change the whole word like this:

arduino = new Arduino(this, "com4", 57600);

RiojT (author)mohitk612016-11-24

"arduino = new Arduino(this, Arduino.list()[0], 57600);"

it is [0] or [1] for even or odd parity

mohitk61 (author)EdwinE52016-11-14

Did you get this issue solved?

SandipK2 (author)EdwinE52015-11-02

Guyz I have problem saying Null Pointer Exception

can anyone help me?

Thanks a Lot

amandahydar (author)SandipK22016-07-21

Hey did you figure out what the problem was? I am having the same error :(

MINAHATESYOU (author)EdwinE52015-11-12

im having the same problem. did you figure out a solution? our arduino board is lighting to the beat but the LEDs are not and the wiring seems to be right.

TechnoTony (author)MINAHATESYOU2016-02-14

What do you mean by the Arduino board is lighting to the beat? The RX LED on the Arduino?

Hey, I had the same prob! To fix wire everything up without the resistors. Like this:

Babam&LeeBoyY (author)EdwinE52015-12-02

Hey, I had the same prob! To fix wire everything up without the resistors. Like this:

CornWars (author)EdwinE52015-11-12

have the exact problem. It loads on the arduino but does not show up on the LED lights, can someone please help

Babam&LeeBoyY (author)CornWars2015-12-02

Hey, I had the same prob! To fix wire everything up without the resistors. Like this:

RonJ11 (author)2015-10-10

I have and error and its all ports are busy :/
any solutions?

mohitk61 (author)RonJ112016-11-15

I know it seems silly but change Cable connecting UNO to computer.
see physical connection on:

JamesF238 (author)2016-10-23

If everything (all the code) seems to be running fine, but your LEDS just wont light up

try changing the line to

arduino = new Arduino(this, "/dev/cu.usbmodem1411", 57600);

where the part inbetween the double quotes is your arduino's serial. This can be found on the bottom right of any arduino code page

Agent-M (author)2016-10-19

what about arduino? is code upload interval wise(buffer of course) or compile first and upload the whole rhythm at the start?

-secondly how about if we close the processing and music then what? Arduino will continue to blow the led according?

DanielD347 (author)2016-07-26

Sorry guys...just wondering where and how can I change

==> isRange(int low, int high, int threshold) method as mentioned above??

VietD5 (author)2016-07-20

Night club strobe light - Strobe flash and club disco light that sync with your music beat. Party on!


It provides a FREE handy strobe light to you right in your pocket! It will listen to the music around you and blink the flash on your device, just like a strobe light. Not just that, the phone screen will become a disco light, one might say, strikes at your music beats! That’s NOT all. Swipe your screen and it will give you several majestic hallucinations, sync with your music, of course. This app is just perfect for your party group, large or small, or even for enhancing your personal musical experience. Bring your phones together and party is just one tap away!

Playing media via bluetooth devices will be disabled during using session of the app due to the low quality sound limited by Apple.

- Strobe light syncs with your music
- Disco light syncs with your music
- Hallucination effects, sync with your music
- Sensitivity adjustment by quick or accurate mode, with good visual presentation.
- Torch light support, for..ehhm… finding objects you drop on the floor for example.
- Listen to music from around you or right from your phone
- Futuristic design, smooth animation
- Tap the screen light button (on the left) to activate disco light and screen light effects.
- Tap the strobe light button (on the right) to activate strobe light effect. Tap again to switch to torch light mode.
- You will see the music reflects on the slider bar in color. Once the color bar exceed the pointer on the slider, flash light will strike. This is how you control sensitivity.
- For quick configuration, just tap on the marks on the slider to adjust the sensitivity. Move your finger on the slider (you don’t have to place your fingertip exactly on the pointer) for more accurate result.
- Swipe left or right to change screen effect and hallucinations.

Link ios:

link preview:

About This Instructable




More by Hyrulian:How to Make LEDs Flash to Music with an Arduino
Add instructable to: