Go Down

Topic: I2C - how does that work? (Read 993 times) previous topic - next topic

alkopop79

I can't wrap my head around how I2C works with Arduino. I was checking examples and tutorials where two Arduinos are connected using I2C and analog 4 and 5 are connected, as well as ground, like here:

http://arduino.cc/en/Tutorial/MasterWriter

Reading multiple tutorials I don't doubt that it works yet it seems to defy logic to connect two analog inputs. How on Earth can anyone send bytes over two connected inputs??? How does the master send anything over an analog input? Thank you for your answers in advance!

retrolefty


I can't wrap my head around how I2C works with Arduino. I was checking examples and tutorials where two Arduinos are connected using I2C and analog 4 and 5 are connected, as well as ground, like here:

http://arduino.cc/en/Tutorial/MasterWriter

Reading multiple tutorials I don't doubt that it works yet it seems to defy logic to connect two analog inputs.

Don't confuse the primary use of a given arduino pin to it's possible secondary uses. When the I2C hardware controller inside the  AVR 328p chip gets activated by the proper software commands, those analog input pins 4 and 5 are no longer analog input pins, but rather become the 2 I2C clock and data signals. Most arduino I/O pins have more then one purpose, such as pins 0 and 1 being hardware serial pins, if not being used as simple digital input or output pins. Even the analog input pins can be use as digital input or digital output pins if desired.

How on Earth can anyone send bytes over two connected inputs??? How does the master send anything over an analog input? Thank you for your answers in advance!

Once those two pins are turned into I2C clock and data signals, they are no longer analog input pins. And the way I2C communications works, the single I2C data pin can be both an input pin to receive data or an output data to send data, it's said to be a bidirectional signal pin. You really don't have to understand it down to the gory details to utilize I2C modules with your arduino. It's main advantage is that it can be wired to up to 127 external I2C modules/devices/chips and sharing those same to I2C control signal pins, as each device has a unique I2C hardware address that allows the master I2C device (usually the arduino) to manage all those devices without conflicts.
Lefty


Nick Gammon

http://www.gammon.com.au/i2c

Quote
... it seems to defy logic to connect two analog inputs ...


When I2C is activated it "takes over" those pins for the I2C functions.

alkopop79

Thank you very much! Now it all makes sense. So much to learn...

Zapro


Go Up