Go Down

Topic: Re: Get Ipod Name (receiving data from Ipod) (Read 784 times) previous topic - next topic


Feb 05, 2009, 11:33 am Last Edit: Feb 05, 2009, 11:34 am by melka Reason: 1
How is the iPod connector wired ?
It seems you're using the Rx/Tx pins of the arduino (0 & 1) to send serial commandes to the iPod.
But those pins are also the one wired to the FTDI which allows serial communication between the Arduino and the computer.
You can't have 2 devices on those pins.
I think you should use the SoftwareSerial library to communicate to the iPod, and leave the Rx/Tx pins unconnected so that the hardware UART can communicate with the computer.



Thanks Melka, that makes sense. I did in fact have the Arduino hooked up to Tx and Rx. I have changed the connection to 2 & 3 and I'm using SoftwareSerial to try to connect with the Ipod but I'm not getting a connection. I don't know what I'm dong wrong.

Here is the latest code. Thank you for the help. I am a n00b.

#include <SoftwareSerial.h>

#define txPin 2
#define rxPin 3

SoftwareSerial podIn =  SoftwareSerial(rxPin, txPin);

int buttonRelease[] = {
 0xFF, 0x55, 0x03, 0x02, 0x00, 0x00, 0xFB };
int playPause[] = {
 0xFF, 0x55, 0x03, 0x02, 0x00, 0x01};

void setup() {
 pinMode(rxPin, INPUT);
 pinMode(txPin, OUTPUT);

void loop() {


int chkSum(int a[]) {
 int t = 0;
 for (int i=2; i<a[2]+3; i++) {
   t = t+a;
 int sum = 0x100 - (t) & 0xFF;
 return sum;

void sendCommand(int cmd[]) {

 int cs = chkSum(cmd);
 podIn.println(cs, HEX);
 cmd[cmd[2]+3] = cs;
 for (int i = 0; i < cmd[2]+4; i++) {
   podIn.print(cmd, BYTE);
 for (int i = 0; i < 8; i++) {


Sorry, I won't be able to help you further, I've never used the SoftwareSerial library.

Do you have an iPod serial communication informations source somewhere ? My first guess would be about the speed. On your first sketch, you use the serial connection at 19200, but the softwareSerial won't run faster than 9600 bauds. Maybe that's an issue.



Are you aware that you need a 500ohm resistor on the Serial Enable pin of the ipod connector to gnd? I think there is a post on here somewhere with some code that works, but it only does play, FF RW, Pause and menu.


Correct me if i'm wrong, but it doesn't look like you're ever calling podIn.begin(baudrate).  That could explain why you're not writing anything, the software serial port never gets started in the code you posted.  And if you are trying to use a baudrate over 9600, you might want to look into the af_softserial library here:http://www.ladyada.net/make/eshield/download.html  It's a reimplementation of softwareserial that handles speeds up to 57600.


Here's my code to control an iPod through the arduino serial pins:


Code: [Select]

/*  Control iPod/iPhones from Arduino
   Sheldon Stokes
   Jan 3, 2009
   Standing on the shoulders of ipodLinux.org
   This send comands to the iPod as though it were a remote.
   These are the simple 2 byte commands that should work on all
   Apple iPods and iPhones starting with the 3rd Generation iPod
   *********** Commands (array index, command value, command description) **************
     0  0x00  Button Release
     1  0x01  Play/Pause
     2  0x02  Vol+  
     3  0x04  Vol-
     4  0x08  Skip >
     5  0x10  Skip <
     6  0x20  Next Album
     7  0x40  Prev Album
     8  0x80  Stop

int commandBytes[]={0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
int checkSum;

int playPin = 2;
int stopPin = 3;
int fwdPin = 4;
int backPin = 5;

int playVal, stopVal, fwdVal, backVal;

void setup()
   pinMode(playPin, INPUT);
   pinMode(stopPin, INPUT);
   pinMode(fwdPin, INPUT);
   pinMode(backPin, INPUT);    

void loop()

   playVal = digitalRead(playPin);  // read play button
   stopVal = digitalRead(stopPin);  // read stop button
   fwdVal = digitalRead(fwdPin);  // read fwd button    
   backVal = digitalRead(backPin);  // read back button

 if (playVal == LOW)
   sendRequest(commandBytes[1]);    // send play command
   sendRequest(commandBytes[0]);    // send button release
 else if (stopVal == LOW)
   sendRequest(commandBytes[8]);    // send stop command
   sendRequest(commandBytes[0]);    // send button release
 else if (fwdVal == LOW)
   sendRequest(commandBytes[4]);    // send stop command
   sendRequest(commandBytes[0]);    // send button release
 else if (backVal == LOW)
   sendRequest(commandBytes[5]);    // send stop command
   sendRequest(commandBytes[0]);    // send button release


void sendRequest(int val) {
   checkSum = 0x100 - ((0x03 + 0x02 + val + 0) & 0xFF);
   int request[] = {0xFF, 0x55, 0x03, 0x02, 0x00, val, checkSum};

   for (int i = 0; i < 8; i++)
       Serial.print(request[i], BYTE);

Go Up