I'm trying to set up an i2c connection between two arduinos (duemilanove and diecimila). I'm using a program that I've used before, so I know it works, but the hardware doesn't work for some reason.
I have connected the ground pins of both arduinos with a hookup wire.
I have connected both 5v pins of both arduinos to my breadboard (row 0)
I have two resistors connected to row 0 as well
I connected the other side of those resistors to rows 1 and 2
I connected pin 4 of both arduinos to row 1
I connected pin 5 of both arduinos to row 2
I hope my description is satisfactory. Do any of you see any problems with my curcuit?
P.S. This is one of my first posts, so if this is the wrong place or format, please let me know.
void setup() {
Wire.begin(4); // join i2c bus with address #4
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
pinMode(LED_OUT, OUTPUT);
digitalWrite(LED_OUT, LOW);
x = 0;
}
void loop() {
if (x > 0) {
for (int i=0; i<x; i++) {
digitalWrite(LED_OUT, HIGH);
delay(200);
digitalWrite(LED_OUT, LOW);
delay(200);
}
x = 0;
delay(1000);
}
delay(100);
}
// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany) {
x = Wire.receive(); // receive byte as an integer
}
I was wondering for a while as well if I should use analog or digital 4 and 5. Reading the specs led me to try analog first, but I was not entirely sure. Perhaps this could be written more explicit, especially where I looked first: http://arduino.cc/en/Main/ArduinoBoardNano