Introduction: Arduino + IPod
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.
Step 1: What You Need
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)
Step 2: Schematic
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.
Step 3: Code Info
Basic comunication protocol. Dont worry, everything is in the code file.
My sources:
http://web.student.tuwien.ac.at/~e0026607/ipod_remote/ipod_ap_new.html
http://www.adriangame.co.uk/ipod-acc-pro.html
http://pinouts.ru/Devices/ipod_pinout.shtml
Step 4: 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
}
Attachments
Step 5: Assembly
Solder the ipod dock
Solder the arduino cables
Solder pushbuttons and resistors.
Solder the audio jack.
Step 6: Place It in a Box
I used my ipod touch box.
You can also add some leds. Its all up to you.
Step 7: The Thing Finished
Yeah, my buttons aref poor quality.
http://www.youtube.com/watch?v=48pZSFSIGjw
Participated in the
Hack It! Challenge