Problem
I have an Arduino Duemilanove which needs to communicate with an Ardiuno Mega. The only pin available on the Duemilanove is D13. The Duemilanove is in charge of driving state on my robot, and the Mega is in charge of sensor readings and navigation. The Mega needs to send drive state updates to the Duemilanove. I2C, PWM, Serial, anything requiring different pins on the Duemilanove is out of the question at this point.
Idea I plan to have the Duemilanove send the "pipe" pin high, triggering an interrupt on the Mega. The ISR will send the current drive state to the Duemilanove which will change pinmode and read a digital pulse. The length of the pulse is the drive state.
Roadblock I am having trouble finding an example of how to set this up. I can't get the ISR to fire, and I'm not sure why.
Mega Code
int pipe = 18;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(pipe, INPUT);
attachInterrupt(digitalPinToInterrupt(pipe), driveStateISR, CHANGE);
}
void loop() {
// put your main code here, to run repeatedly:
}
void driveStateISR(){
Serial.println("ISR fired");
pinMode(pipe, OUTPUT);
digitalWrite(pipe, HIGH);
delay(50);
digitalWrite(pipe, LOW);
Serial.println("Pulse sent!");
pinMode(pipe, INPUT);
}
Duemilanove Code
int pipe = 13;
void setup() {
// put your setup code here, to run once:
pinMode(pipe, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(pipe, HIGH);
delay(30);
pinMode(pipe, INPUT);
unsigned long duration = pulseIn(pipe, HIGH);
Serial.println(duration);
delay(3000);
}
Nothing happens at all. I'm thinking the main framework is here, but since there aren't many examples of this out there I'd love to get some other eyes on the issue. Thanks!