Arduino + IPod

by dan95 in Circuits > Arduino

36327 Views, 40 Favorites, 0 Comments

Arduino + IPod

HPIM1126.JPG
IMG_0088.JPG
Easily control your iPod with Arduino using serial commands. This instructable includes the schematic, the code and some extra info; everything you need to make this work. 

USB,battery or wall power supply powered.

What You Need

IMG_0049.JPG
IMG_0071.JPG
IMG_0075.JPG
IMG_0078.JPG
Parts:
5x  1K ohm resistors
2x  1M ohm resistors
1x  12K ohm resistors
1x  1.5K ohm resistors
4x  normaly opened push buttons
wire
protoboard (optional)
3.5mm audio jack

Arduino Uno or similar    http://arduino.cc/
recycled iPod Dock or PodBreakout ( you can buy it here http://www.sparkfun.com/products/8295)

Schematic

ipod control_bb.jpg
IMG_0072.JPG
In the protoboard.
Arduino serial is 5v while iPod logic level is 3.3v. Because of it we need to add a voltage divider.
The two 1M ohm resistors are required to make a 500k to select the device.
The dectect cable is conected to iPod TX pin and use to let the arduino know when an ipod is conected.


Code Info

Code structure.jpg
Commands.jpg

Download the Program

Here is the arduino code:

/*
By Daniel Solis
Licensed under Creative Commons Attribution-ShareAlike 3.0 Unported
http://creativecommons.org/licenses/by-sa/3.0/

You are able to modify this code as well as the hardware. If you
have a better code or make any changes that improve the performa
nce please share them

Analog pin 4: ipod TX(to detect ipod)
Analog pin 0: button detection
Digital pin 1: arduino TX
*/

byte mode2[]={0xFF,0x55,0x03,0x00,0x01,0x02,0xFA};//mode 2 command
byte nobutton[]={0xFF,0x55,0x03,0x02,0x00,0x00,0xFB};//button release command
int release=200;
//commands
byte playxpause=0x01;
byte nextsong=0x08;
byte prevsong=0x10;
byte shuffle[]={0xFF,0x55,0x04,0x02,0x00,0x00,0x80,0x7A};
int long time;//
int butbefore=1023;
int dockbef=0;


void setup()
{
Serial.begin(19200);//sets serial com
for(int p=0; p<7; p++)
{Serial.print(mode2[p],HEX);}//sends mode2 command
}

void loop()
{
  int dock=analogRead(4);
  if(dock!=dockbef)//checks if there is an iPod conected
  {
   for(int p=0; p<7; p++)//if not, it sends again mode2 command
   {Serial.print(mode2[p],HEX);}
  }
int butnow=analogRead(0);
    if(butnow!=butbefore&&millis()-time>release)
    {
       if(butnow!=HIGH)//wait for button pressed
      {
       time=millis();
       if(butnow==0)//
       {
       srlcommand(playxpause);
       }
       if(butnow >948 && butnow<953)
       {
       srlcommand(nextsong);
       }
       if(butnow >=506 && butnow<508)
       {
       srlcommand(prevsong);
       }
       if(butnow >955 && butnow<963)
       {
         for(int d=0; d<8; d++)
        {Serial.print(shuffle[d],BYTE);}
       }
      }   
    }
else
{
  for(int d=0; d<7; d++)
  {Serial.print(nobutton[d],BYTE);} //no button pressed command
}
butbefore=butnow;
}


void srlcommand(byte select)
{
  byte checksum=0x00-0x03-0x02-0x00-select;//checksum of lenght, mode and command
  byte inst[]={0xFF,0x55,0x03,0x02,0x00,select,checksum};//general structure
  for(int m=0; m<7; m++)
    {Serial.print(inst[m],BYTE);}//sends the command
}

Downloads

Assembly

IMG_0042.JPG
IMG_0043.JPG
IMG_0079.JPG
IMG_0074.JPG
IMG_0075.JPG
Solder the ipod dock
Solder the arduino cables
Solder pushbuttons and resistors.
Solder the audio jack.

Place It in a Box

IMG_0073.JPG
IMG_0080.JPG
IMG_0082.JPG
IMG_0083.JPG
HPIM1128.JPG
HPIM1132.JPG
I used my ipod touch box.
You can also add some leds. Its all up to you.

The Thing Finished

Yeah, my buttons aref  poor quality.

http://www.youtube.com/watch?v=48pZSFSIGjw