I've tried hooking up 2 arduinos using I2C and I need to expand it to 3 now cause of the Razor IMU sensor, which is also an Arduino.
As the I2C uses analog pins 4 & 5, how do the master Arduino knows which slave it is talking to?
Thanx guys. I realised my mistake, which is that the address is defined in the setup loop.
Kinda confused that with the pin no.
Take a look at the code I used for my MiniEric robot, I have 4 Arduinos communicating by I2C. All of them start with a slave address and wait for incomming messages but they can became masters at any time they need. Just download the file R-Dev-Ino.zip, has all the needed files included.
I mean, you had to have set a slave address and then "called to" that slave address by the master, right? What do you have it set to now? When you used the wire.begin(x), what was the "X" you used? Well, whatever it is, use a different number for the next chip.
Have you not googled this? There are at least 3 instructables on how to do this. I think one is called, "how to interface 3 arduinos using i2c"
Ok, but the default address on the arduino is 4 right?
Or how do I set the address on the arduino?
The master sends a start sequence then a device address with a read/write bit. After that only the slave device with the matching address listens until you start another I2C transmission. There's more to it but that's the gist of it.