Hi all,
I'm trying to get two arduinos to communicate over i2c. I have it basically working, with the two transferring data both ways. However, when I first plug in the pair, they will not communicate until I reset the slave.
I connected the 5V, Gnd, A4, and A5 pins of an uno r2 and an uno r1 together and attached a 9v battery to one of them (pictures attached). On the "master", I put this sketch
// master.ino
#include <Wire.h>
void setup() {
pinMode(13, OUTPUT);
Wire.begin();
do {
Wire.requestFrom(12, 1);
} while (Wire.available() < 1);
}
void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
and on the slave I put this sketch
#include <Wire.h>
uint8_t var[1];
void i2cRequest() {
Wire.write((uint8_t *)var, 1);
}
void setup() {
Wire.begin(12);
Wire.onRequest(i2cRequest);
}
void loop() {}
The light on the master does not flash until I reset the slave by hitting the reset button; then it flashes. Resetting the master does nothing.
It seems to me the most likely culprit is a bug in the Wire libraries, since this sketch and the wiring is extremely simple and I've duplicated the results on several different wiring setups and sketches. I'm using a freshly-downloaded 1.0.3 IDE