Introduction: RGB Flashing IPod Dock From an Old Speaker!

About: I love arduino and electronics in general. I enjoy tinkering and various other geeky activities. I also like studying Japanese.
Edit: I've entered in the LED contest, Hurricane Lasers, and Fix & improve it contest. If you like this, please vote.

Original Video - song: river of dreams by billy joel

Using an Apple Pro speaker, I made a flashing RGB LED iPod dock for about $35.
I recommend reading the entire 'ible before starting. Also, note that the volume is control from the iPod.
It consumes minimal power in shutdown mode, and is controlled by a Teensy.
This took me ~3 days to build, and you should know how to solder pretty well before doing this project.
The enclosure looks amazing when lit, it is really fun to watch it.

Step 1: Gather Tools & Materials

Tools:
Soldering Iron
Hot Air gun/Hair dryer
Hot glue gun/epoxy
Drill (or dremel)
Screwdriver
Sandpaper (fine grit)
Wire strippers

Parts:
(1) Teensy 2.0
(1) Sparkfun RGB LED breakout
(1) Sparkfun Mono Audio amp breakout
(1) Apple pro speaker (You only need one speaker, not the set)
(1) Mini-USB cable (will be cut up)
(1) iPod-USB cable (also will be cut)
(1) Audio plug
(1) Push-on/Push-off button
(1) 10K ohm resistor
(1) Roll of solder
(1) Headphone foam cover (black foam circles found on old headphones, I had a few lying around.)
Assorted heat shrink 
Ribbon cable or other thin wire

Step 2: Disassemble the Speaker

To open the apple pro speaker, unscrew the three screws around the rim of the speaker. Remove the speaker and cut the wires. Keep the speaker aside, and pull the thick white wire out of the speaker. Discard it. Save all three screws.

Step 3: Drill and Sand the Speaker

Drill a hole as large as the iPod cable into the top center of the speaker. Drill slightly fast or the plastic will crack. Then, using a thinner bit, remove all the foam/stuff from the metal hole where the wire used to come out of. Drill until you can slide 7-wire ribbon cable inside.
Remove the ribbon cable, and sand with fine grit paper until the enclosure is smooth, translucent, and will blend light well.

Step 4: Connect +5v and GND to Everything.

Take your iPod cable and cut it ~2" from the iPod connector. Take the iPod side and push it through the hole you drilled on the top. Using wire strippers, carefully remove 1/2 centimeter of the outer white insulation. There will be 4 wires, and the braided shielding. move the braided shielding to the side and cut it off. Strip the green and white wires, and twist them together. Solder. Strip the red and black wires, and solder two pieces of ribbon cable to them (Make sure that the red and black are not in contact). Those are the power and ground. Heatshrink all your connections. Take your Mini-USB cable and cut it ~2" from the mini side. Put that aside for now. Take your Teensy, and solder a wire from the Vcc and GND pins  (left and right of the USB jack) to the corresponding Vcc/GND that you just soldered to the iPod wire. Remember, this is all inside the apple pro enclosure. DO NOT HEATSHRINK THIS CONNECTION yet. Take the Sparkfun audio amp and solder two wires to its Vcc/GND pins.  Connect the other ends to the connections you made between the teensy and the iPod connector. (We'll call these the Vcc and GND "hubs"). Take your Sparkfun RGB breakout, and assemble it. (Instructions)
Solder 5 wire ribbon cable to the output pins. Leave the three R/G/B wires alone, and connect Vcc and GND to our "hubs". Now that the hubs are finished, you can put some heatshrink over the top and shrink!

Step 5: The LED's and Speaker

Looking at this Teensy pinout, I see that pins 12, 14, and 15 are PWM pins. PWM is a way to change brightness with a square wave. For more in-depth description of PWM, go to the Arduino page. Solder the R/G/B wires to the pins 12, 14, and 15. Now, solder two wires to the speaker. Solder them to the sparkfun audio amp's OUTPUT wires. Polarity is unimportant. Take a 7-wire piece of ribbon cable (about 6" long) and push it through the silver hole in the back. Take the Mini-USB side of the cable we cut earlier, and plug it into the teensy. Strip 1/2 cm of insulation. There will be 4 wires, and a braided shielding. I decided not to connect the braided shielding. The shielding stops possible EMI or any kind of static. My device works without it. So, cut the shielding off. Connect all four wires (red, black, green, white) to wires in the 7-wire ribbon cable, solder, and heatshrink. Then solder two wires to the INPUT of the audio amp. Solder the other end to two more of the ribbon cable wires.

To recap: The speaker is connected to the OUTPUT of the amp, The 4 Mini-USB wires and the INPUT of the amp are connected to 7-wire ribbon cable leaving one wire, The RGB leds are connected to PWM pins, and the mini-USB is plugged into the teensy.

Step 6: Audio-In and Finishing the Inside.

Take the two wires on the outside of the 7-wire cable that are connected to the Audio-INPUT, and take the Mono audio cable. If you don't have this cable, take a stereo cable and connect only negative and one input (I used scissors to hack apart the end of the cable, and I found just the metal plug. I soldered gnd and positive input to the two wires coming out of the cable.) (Yeah, this is sort of confusing. Comment for help. And to clarify, DO NOT connect the negative audio to to negative power.) This should be long enough to connect to the iPhone audio jack without being too tight. Now, you should look inside and find the audio amp's volume control pins. Solder a wire to the center pin, and to the teensy analog input 1. Solder a wire from the pin labeled SDN to any of the teensy digital pins. (I used 24)
Finally, solder a wire from teensy pin 19 to the remaining wire in the 7-wire ribbon cable. Connect a 10K resistor from pin 19 to GND.

Also, I noticed that placing an led just inside the rim of the speaker made it glow nicely. I didn't put this, but just wanted to write it.

Check all you connections twice with multimeter, heatshrink all of them. Put electrical tape on the underside of each pcb. The area is quite cramped and it may short. Slowly push everything into the enclosure. Make sure the Audio amp isn't too close to the leds or the PWM signal will cause a buzzing from the speaker when on. Put the speaker on, put the black headphone cover over the speaker. Screw in the three screws from when you disassembled it. Almost done!

Step 7: Return of the 7-Wire Cable

Now, look at the seven wire cable. Hopefully you know which wire is connected to what inside. So, solder the wire connected to digital 19
to one end of the pushbutton (Make sure it's a push-on/push-off). Connect the other end of the button to positive. Take the other, long part of the Mini-USB cable (the one with a regular usb plug) and strip the insulation. Cut the braided shielding, and solder the corresponding wires. (White to white, Green to green, Positive to Red, Negative to Black). You may have used different colored ribbon cable, just make sure the wires are the same on the inside. Use large heat shrink to covered the whole thing. Make sure the button is accessible. Final check: check all the connections outside, make sure all the internal parts don't move, etc. Hot glue some where it shows in the second pic. I screw a right angle piece of metal there.

Step 8: Programming

Here is the program I wrote. My beat reading algorithm is not standard but works very well. Plug the newly soldered usb cable into the computer, open the arduino software, (you will need to install the teensy add on). Open my prog, upload to the teensy,
and test all functions. The device should flash red twice and turn off when you press the pushbutton. Press again, it should flash twice green and turn on. If not, comment! ask questions! Please give feedback. If you make one, take a picture and post it!

/* ipod_dock - software for ipod dock*/
int red = 0;
int blue = 0;
int green = 0;
int redPin = 12;  // Set the pins for the red, green and blue LEDs.
int greenPin = 14;
int bluePin = 15;
int oldVal, a;
int ampPin = 24; // amp shuhtdown pin
int buttonPin = 19; //shutdown button pin
int sensorValue;
void setup() {
pinMode(ampPin, OUTPUT);
pinMode(buttonPin, INPUT);
randomSeed(A0);


a = strt();
   delay(3000);
}

void loop() {


if (digitalRead(buttonPin) == LOW)
{
a = stdn();
}
int y = beat_read();
}
int beat_read()
{
   int oldVal = (analogRead(A1));
  int sensorValue = analogRead(A1);
red = random(1, 255);
  blue = random(1, 255);
  green = random(1, 255);


red = 255 - red;
blue = 255 - blue;
green = 255 - green;
  analogWrite(redPin, red);
  analogWrite(greenPin, 2*(green));
   analogWrite(bluePin, 2*(blue));
  while ((analogRead(A1)) > (oldVal - 5) & (analogRead(A1)) < (oldVal +  5)) // switch 5 with anything for increased or decreased sensitivity
{
  delay(10);
if (digitalRead(buttonPin) == LOW)
{
a = stdn();
}
}
}


// shutdown function
int stdn()
{
    digitalWrite(ampPin, LOW);

    analogWrite(bluePin, 0);
  analogWrite(greenPin, 0);
  analogWrite(redPin, 255);
  delay(250);
  analogWrite(redPin, 0);
  delay(250);
  analogWrite(redPin, 255);
  delay(250);
  analogWrite(redPin, 0);



  while (digitalRead(buttonPin) == LOW)
  {
delay(5);


  }
int x = strt();
}

//start function
int strt()
{
    digitalWrite(ampPin, HIGH);

    analogWrite(bluePin, 255);
  delay(250);
  analogWrite(bluePin, 0);
  delay(250);
  analogWrite(bluePin, 255);
  delay(250);
  analogWrite(bluePin, 0);
}


Enjoy the music!!

LED Contest with Elemental LED

Runner Up in the
LED Contest with Elemental LED

Hurricane Lasers Contest

Participated in the
Hurricane Lasers Contest

Fix & Improve It Contest

Participated in the
Fix & Improve It Contest