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.


1. An Arduino microcontroller board. There are many versions of the Arduino, but I would recommend the Arduino UNO.

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

Step 3: CODING:-


* This sketch demonstrates how to use the BeatDetect object i

import processing.serial.*; import ddf.minim.*; import ddf.minim.analysis.*; import cc.arduino.*;

Minim minim; AudioPlayer song; BeatDetect beat; BeatListener bl; Arduino arduino;

int ledPin = 12;

// LED connected to digital pin 12

int ledPin2 = 8;

// LED connected to digital pin 1

int ledPin3 = 2;

// LED connected to digital pin 0

float kickSize, snareSize, hatSize;

void setup() {

size(512, 200, P3D); minim = new Minim(this);

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

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

song.play(); // a beat detection object that is FREQ_ENERGY mode that // expects buffers the length of song's buffer size // and samples captured at songs's sample rate

beat = new BeatDetect(song.bufferSize(), song.sampleRate()); // set the sensitivity to 300 milliseconds // After a beat has been detected, the algorithm will wait for 300 milliseconds // before allowing another beat to be reported. You can use this to dampen the // algorithm if it is giving too many false-positives. The default value is 10, // which is essentially no damping. If you try to set the sensitivity to a negative value, // an error will be reported and it will be set to 10 instead.


kickSize = snareSize = hatSize = 16;

// make a new beat listener, so that we won't miss any buffers for the analysis

bl = new BeatListener(beat, song); textFont(createFont("Helvetica", 16)); textAlign(CENTER); arduino.pinMode(ledPin, Arduino.OUTPUT); arduino.pinMode(ledPin2, Arduino.OUTPUT); arduino.pinMode(ledPin3, Arduino.OUTPUT); }

void draw() {



if(beat.isKick()) { arduino.digitalWrite(ledPin, Arduino.HIGH); // set the LED on kickSize = 32; } if(beat.isSnare()) { arduino.digitalWrite(ledPin2, Arduino.HIGH); // set the LED on snareSize = 32; } if(beat.isHat()) { arduino.digitalWrite(ledPin3, Arduino.HIGH); // set the LED on hatSize = 32; } arduino.digitalWrite(ledPin, Arduino.LOW); // set the LED off arduino.digitalWrite(ledPin2, Arduino.LOW); // set the LED off

arduino.digitalWrite(ledPin3, Arduino.LOW); // set the LED off textSize(kickSize);

text("KICK", width/4, height/2);


text("SNARE", width/2, height/2); textSize(hatSize); text("HAT", 3*width/4, height/2); kickSize = constrain(kickSize * 0.95, 16, 32); snareSize = constrain(snareSize * 0.95, 16, 32); hatSize = constrain(hatSize * 0.95, 16, 32); }

void stop() {

// always close Minim audio classes when you are finished with them

song.close(); // always stop Minim before exiting

minim.stop(); // this closes the sketch super.stop(); }

<p>I haave the oddest feeling you copied this instructable: </p><p>https://www.instructables.com/id/How-to-Make-LEDs-Flash-to-Music-with-an-Arduino</p>

About This Instructable




More by appytechie:Program the Linkit One Using a Raspberry PI Linkit One Controlled El-wire Linkit One - Dice  
Add instructable to: