So, I've run out of compiling errors, but I still get no response from the iPod.
This is where the code stands:
#include <iPodSerial.h>
#include <SimpleRemote.h>
SimpleRemote simpleRemote;
// initialize
int pingPin = 7 ; // Serial for Ping)))
int podPin = 0 ; // IPod TX, board RX
int podPout = 1 ; // IPod RX, board TX
int pingBaud = 9600 ; // Ping))) Baud rate
int podBaud = 19200 ; // IPod Baud rate
int threshOn = 20;
int threshOff = 40;
// set up
void setup() {
iPodSerial(); // Setup iPodSerial
}
unsigned long pp = 0;
void loop() {
simpleRemote.sendiPodOn();
delay(50);
simpleRemote.sendButtonReleased();
simpleRemote.sendPlay();
delay(5000);
}
/*
pp = Ping();
while (pp > threshOn){
delay(500);
break;
}
if (pp < threshOn) {
simpleRemote.sendiPodOn();
delay(50);
simpleRemote.sendButtonReleased();
simpleRemote.sendPlay();
while (pp < threshOff){
pp = Ping();
delay (500);
}
}
simpleRemote.sendiPodOn();
simpleRemote.sendButtonReleased();
simpleRemote.sendPlay();
simpleRemote.sendSkipBackward();
}
*/
unsigned long Ping(){
Serial.begin(pingBaud);
int x = 0;
pinMode(pingPin, OUTPUT) ;
digitalWrite(pingPin, LOW) ; // init sensor to ensure clean HIGH pulse
delayMicroseconds(2) ;
digitalWrite(pingPin, HIGH) ; // make the sensor send a pulse
delayMicroseconds(5) ;
digitalWrite(pingPin, LOW) ; // Set LOW again
pinMode(pingPin, INPUT) ; // Get ready to capture the duration of the resulting pulse
// Capture how long the pin stays in HIGH state.
unsigned long Duration = pulseIn(pingPin, HIGH) ;
x = Convert_Time_Space(Duration) ;
delay(500);
return x;
}
unsigned long Convert_Time_Space(const unsigned long fnDuration )
{
// I used 29 microseconds per cm.
// 40kHz supersonic burst
// 1130 fps -> 29.0339814 microseconds per cm
return fnDuration / 29 / 2 ;
}
and as for hardware, it's right outta this:
http://www.flickr.com/photos/finsprings/4403179910/lightbox/
With the exception that my power runs straight from 5v to the iPod, since it actually charges that way. But since that has nothing to do with TX/RX, forget it.
Anyone see what I'm doing wrong here?