I am offloading the sound effects from my Arduino Fio to a 2nd Fio, since the Wire and SD libraries don't play nice together. I was running out of RAM. See this post: SD.h not compatible with other libraries in Arduino/C++ environment - Stack Overflow
In order to let one Arduino signal another Arduino, I am trying to use a pulse on a digital pin, then sample four other pins to read an index. But the trigger is not working as expected. It seems that the signal is ringing for up to a second! I didn't expect that.
Here is the code of the 1st Arduino, the sender:
digitalWrite(SOUND_0, LOW);
digitalWrite(SOUND_1, LOW);
digitalWrite(SOUND_2, LOW);
digitalWrite(SOUND_3, LOW);
// Pulse pin 4, connected to pin 2 on wav Fio
digitalWrite(SOUND_PULSE, HIGH);
delay(1);
digitalWrite(SOUND_PULSE, LOW);
Here is code of the 2nd Arduino, the listener:
void loop() {
//unsigned long pulse = pulseIn(2, HIGH);
if (digitalRead(2))
{
Serial.print("Found the pin switch!");
}
delay(100);
}
When I do this I get lots of messages that it found the pin switched, which means that it is still finding it high after the 100ms delay on the listener. How do I just find it one time? I want the signal from the 1st Arduino to trigger the 2nd with a quick pulse, and then sit quietly until the next sound effect is needed. I have tried changing the polarity of the signal and turning on the internal pullup of the listener by driving a high or low on the pin even though it is receive mode. i.e.
pinMode(2, INPUT);
//digitalWrite(2, LOW); // Enable pullup resistor on the trigger
pinMode(3, INPUT);
pinMode(5, INPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
Any ideas?