Who needs auto-tune when you have an Arduino board and LEDs?

When I learned that this project entailed LEDs, the first thought that came to mind was how I could combine the main task of flashing an LED and relate it to music. Rihanna’s “Disturbia” has a prominent introductory beat that I thought would be the perfect complement to a flashing light. However, rather than using just one light, I chose to program three LEDs to flash at different rates depending on which part of the chorus it was.

First, I connected one jumper wire from GND on the Arduino board to the negative rail on the breadboard. I then connected three other jumper wires from rows 10-13 on the Arduino board to a positive row on the breadboard. Next, I used the remaining three jumper wires to act as resistors for the wires connected to the Arduino board by connecting one end to the negative rail and the other end above the other wire on the breadboard (view photos for clarification). Finally, I connected the LEDs to the breadboard by putting the positive side (longer leg) below the wire connected to the Arduino board and I put the negative side (shorter leg) under the port that connects the negative rail. Now, the physical components of my board were ready. The final step was to write code that would make the lights flash to the beat of the song. After using code provided by Arduino and tweaking the HIGH and LOW voltage levels for each light, I was able to create a light show that corresponded to Rihanna’s “Disturbia”.

Components used:

  • 1 Arduino Uno
  • 1 Breadboard
  • 3 LEDs
  • 7 jumper wires
  • 1 USB cable

Code:
int ledgreen = 13; //(green)
int ledblue = 12; //(blue)
int ledred = 11; //(red)

// the setup routine runs once when you press reset:
void setup()
{
// initialize the digital pin as an output.
pinMode(ledgreen, OUTPUT);
pinMode(ledblue, OUTPUT);
pinMode(ledred, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop()
{
digitalWrite(ledgreen, HIGH); // turn the LED on (HIGH is the voltage level)
delay(240); // wait for a second
digitalWrite(ledgreen, LOW); // turn the LED off by making the voltage LOW
delay(240);
digitalWrite(ledgreen, HIGH); // turn the LED on (HIGH is the voltage level)
delay(240); // wait for a second
digitalWrite(ledgreen, LOW); // turn the LED off by making the voltage LOW
delay(240);
digitalWrite(ledblue, HIGH);
delay(150);
digitalWrite(ledblue, LOW);
delay(225);
digitalWrite(ledred, HIGH);
delay(100);
digitalWrite(ledred, LOW);
delay(250);
digitalWrite(ledblue, HIGH);
delay(250);
digitalWrite(ledblue, LOW);
delay(250);
digitalWrite(ledblue, HIGH);
delay(250);
digitalWrite(ledblue, LOW);
delay(250);
digitalWrite(ledred, HIGH);
delay(200);
digitalWrite(ledred, LOW);
delay(150);
digitalWrite(ledblue, HIGH);
delay(250);
digitalWrite(ledblue, LOW);
delay(175);
digitalWrite(ledred, HIGH);
delay(200);
digitalWrite(ledred, LOW);
delay(225);

}

Arduino Arduino 2

Leave a Reply