Stereo Light Speakers Synchronized to Music With Arduino

by kevinjpower in Circuits > Arduino

1705 Views, 11 Favorites, 0 Comments

Stereo Light Speakers Synchronized to Music With Arduino

Title.png

Ever wanted to have a pair of light speakers that are synchronized to your music? Using an Arduino UNO, a music shield and a string of WS2811 controlled LED’s you can create any combination of sounds and effects.

Supplies

Here is a list of the components used in this project:

  • Arduino UNO
  • VS1053 Music Shield (can be purchased on eBay, Sparkfun, Amazon etc.)
  • SD Card (8 GB in this case but can be another size)
  • 5V WS2811 RGB Full Color Pixel LED light string (50 lights)
  • 9V DC Power Supply
  • 5 V DC 2.5A Power Supply
  • Foam Board
  • Stand alone Stereo Speakers with included amplifier

And the following tools:

  • Glue Gun (to stick foam board together)
  • Drill with 10 mm bit
  • Wire crimper

LED Light String

Wiring3.png
WiringString.png
Wiring2.png

The LED light string used in this project is available for purchase on multiple different sites. It consists of 50 individual RGB LED’s each with a WS2811 IC attached to it.

According to the advertising that goes with the strings they are rated for a IP68 environment, each LED in the string is individually addressable and 20 AWG wire joins them together. Some pictures included.

The strings come in either 5V or 12V configurations. This project uses the 5V version.

The WS2811 works in a three wire configuration – 5V, 0V and data. There are other IC’s on the market that work on a four wire configuration – 5V, 0V, data and clock.

The WS2811 takes as input three bytes of information (24 bits) and uses each individual byte to control the intensity of one of the R, G, and B LEDS in the light. Therefore 0xFFF would be white (all LEDS on), 0x000 would be black (all LEDS off) and 0xF00 would be red (red LED on only). Varying the intensity of the LEDS in this manner can create a large range of colors.

The WS2811 chips in each light are daisy chained together. The controller (in this case an Arduino) sends out a concatenated string of multiple three byte commands to the light string. The first WS2811 takes it’s three bytes and passes on the remainder of the string to the second WS2811. The second WS2811 takes it’s three bytes and passes on the remainder. And so on until all LEDS are lit.

Refer to the WS2811 data sheet for more details.

Because the WS2811 is daisy chained and passes strings on to the next IC, the data lead can only be connected one way to the controller. Incorrect connection will result in a black string of lights. The 5V can be connected to either end of the string.

Long strings can be constructed by connected 50 LED lengths in series. Every 50 LED’s there is provision for injecting 5V into the string to prevent voltage drop from causing extreme ends to become dim. Refer to the schematics available online.

The current draw of a 5V string displaying all white (which is the worst case as all three LEDS are max brightness) is given by the following equation:

I (in mA) = 32.83*(No LEDS) + 17

So 50 LEDS will draw about 1.66 A. When planning large displays, you have to ensure that the power supply driving the strings has sufficient capacity.

Downloads

VS1053 Music Shield

IMG_3736.JPG

This shield can also be obtained from multiple sources. Both Sparkfun and Adafruit make versions of the shield. At its heart is a VS1053 IC which can handle multiple sound playbacks and different recording modes. The shield also includes a Sd Card slot which allows the VS1053 IC to play mp3 files stored on a SD Card.

Refer to the following tutorial on the shield for detailed instructions on how to use it

http://www.billporter.info/2012/01/28/sparkfun-mp3-shield-arduino-library/

For this project we are only using the MP3 shield to play a song off the SD Card. Before continuing with the rest of the project, test to see that the shield will function as required. Use the following steps:

  • Connect the shield to your Arduino
  • Copy an mp3 music file to an SD Card. It should be the only file on the card
  • Because of the limitations of SDFat library, make sure that the file is renamed in 8.3 format e.g. “track001.mp3”. Insert the SD Card into the reader on the shield.
  • Install the library referenced in the “Mind of Bill Porter” article.

https://github.com/madsci1016/Sparkfun-MP3-Player-Shield-Arduino-Library

https://www.elecrow.com/wiki/index.php?title=File:MP3_Shield_libraries.zip

  • The library can be installed in your Arduino IDE using the Sketch → Include library → Add ZIP library...
  • Connect a powered speaker with a audio cable to the SPK jack on the shield
  • Open the code “SimpleMP3Test” in the Arduino IDE and upload it to the Arduino
  • After the Arduino resets, the music file on the SD card will start playing

That was easy

Downloads

FastLED Library

The final code in this project uses the FastLED library to control the LED lights in the string. The library is maintained by Daniel Garcia and Mark Kriegsman. Website:

https://fastled.io/

The website contains lots of information the program, its features and links to documentation.

At this point, make sure that the library is installed in your Arduino IDE. Use the library manager and search for “FastLED”.

Under File → Examples → FastLED → Blink, open the Blink program. Un-comment the line

FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);

Upload the program to the Arduino. The data pin is defined as #3.

To see if this all works, connect a 5V power supply to your light string (and preferably use this power supply to power the Arduino via the barrel jack connector. This ensures a common ground). Connect the data line of the string to pin 3 of the Arduino. Remember that this connection must be at a specific end of the string else the LEDs will not work.

If all is successful, the first LED in the string should blink red on and off at half second intervals.

That was easy

Constructing the Light Speakers

IMG_3723.JPG
IMG_3722.JPG
IMG_3721.JPG

Here are the steps to construct the light speakers:

  • Using an exacto knife (or box cutter), cut 4 strips 3 inches wide.
  • Using a hot glue gun, glue the strips together to give a total length of about 4 ft.
  • Mark hole centers for lights at 2 inch between centers (this project used 23 holes – which is completely arbitrary)
  • Drill holes using a 10 mm drill bit (about 3/8 inch)
  • Install the lights into the holes. A gentle push should pop the lights into the holes.
  • Make sure that the correct end of the data line is at the bottom of the stick
  • This project uses 23 lights per stick

Some photographs included.

Feel free to create any other shape or configuration.

Schematic Diagram

SchematicDiagram.png

Here is the schematic diagram of the final configuration

Two power supplies were required because the VS1053 MP3 Shield would not work if the Arduino is connected to a 5V power supply.

The data pin is set programmatically to 5 (as opposed to 3) because of conflicts with the MP3 shield.

Connect up your light speakers as shown. Make sure that the MP3 shield is connected to the Arduino, and that it is connected to powered speakers via an audio cable.

Programming the Show

Audacity.png
AnimationTable.png

The Arduino program used in this project contains 11 different animations or light patterns.

/- applause (a)

/- begin show fade up(b)

/- confetti (c)

/- beat (d)

/- middle to outer (o)

/- top to bottom (t)

/- fill from one to full (w)

/- juggle (j)

/- sprinkle

/- rainbow (r)

/- beats per minute (m)

Keeping this in mind, the basic steps required to program the light speakers so that they are synchronized to music as follows:

  • Open the mp3 file of the song you want to synchronize in a program like Audacity (Adobe Audition, GarageBand etc.). This particular project used Audacity.
  • Use the position marker to derive the time of a given event in the song. This event is where an animation needs to change. For every animation change that needs to be programmed, note the song time. This should be done in milliseconds.
  • Once you have decided on all the events and animations required to cover the song and their respective start and end times, the data can be transferred to a table.

This data can then be transferred to the light show program. Open the Arduino sketch “FinalShow” in the IDE and scroll down to approx line 160.

Edit the C++ structure with the contents of the table. Animation first and delta time second.

PatternandTime playList[12] = {
{ b, 6831 },
{ d, 21119 },
{ m, 21990 },
{ r, 19274 },
{ m, 40699 },
{ o, 40799 },
{ r, 20746 },
{ c, 20493 },
{ r, 19229 },
{ w, 5468 },
{ d, 12803 },
{ a, 19138 }
};


Downloads

Final Demonstration

Once all this is done, it is time to upload the code to your Arduino. The sketch provided here sets Back in Black by AC/DC (famous song from way back) to the light show.

Upload the code and disconnect from your computer. Make sure the SD Card is in the slot, connect up the circuit and reset the Arduino. The show should begin.

Enjoy and Good Luck!