Rosie Daniel wrote a nice piece of Arduino code to control an iPod. Rosie used a hacked iPod remote to connect her Arduino to the iPod. The remote’s AUD connection is its data in connection, which is connected to the Arduino/Wiring board’s data out. The iPod’s power (VCC) and Ground are connected to the power and ground of the microcontroller. Then this code works.
Thanks to Rosie for writing this:
Technorati Tags: arduino, atmel, serial
//code that controls basic (play/pause, next, previous, volume up, and volume down) functions of ipod //rosie daniel int hits = 0; int buttonStates[]={0,0,LOW,LOW,LOW,LOW,LOW}; int buttonPrevious[]={0,0,LOW,LOW,LOW,LOW,LOW}; int buttonRelease[] = {0xFF, 0x55, 0x03, 0x02, 0x00, 0x00,0xFB}; int commands[]={0,0,0x01,0x08,0x10,0x02,0x04}; int checkSum(int len, int mode, int command1, int command2, int parameter) { int checksum = 0x100 - ((len + mode + command1 + command2+ parameter) & 0xFF); return checksum; } void setup() { Serial.begin(19200); pinMode(2, INPUT); pinMode(3, INPUT); pinMode(4, INPUT); pinMode(5, INPUT); pinMode(6, INPUT); } void loop() { for (int c=2; c<7; c++) { buttonStates = digitalRead(c); buttonStates = digitalRead(c); if (buttonStates != buttonPrevious ) { delay(5); //helps avoid a 'double' press - check a second time to see if the button is still pressed after a delay buttonStates = digitalRead(c); if (buttonStates == HIGH) { sendCommand(commands); //Serial.print(hits); hits++; } buttonPrevious = buttonStates; } } } void sendCommand(int cmd) { int cs = checkSum(0x03, 0x02, 0x00, cmd, 0); Serial.println(cs,HEX); int bytes[] = {0xFF, 0x55, 0x03, 0x02, 0x00, cmd, cs}; for (int i = 0; i < 8; i++) { Serial.print(bytes[i], BYTE); } for (int i = 0; i < 8; i++) { Serial.print(buttonRelease[i],BYTE); } }