hi,
I understand that the current "Wire" library sets Port C4 and Port C5 for I2C. Is there a way to set other ports as I2C comms? Thanks in advance!
hi,
I understand that the current "Wire" library sets Port C4 and Port C5 for I2C. Is there a way to set other ports as I2C comms? Thanks in advance!
I dont think you can do that.
There are libraries that bit-bang I2C communication on other pins. For example, the JeeLabs "Ports" library: http://cafe.jeelabs.net/sw/library_-_ports/
I2C is hardwired into the AtMega168 and 328 to use those pins. See the pin mapping diagram http://arduino.cc/en/Hacking/PinMapping168 for the functions available from these chips to show how they map to the Arduino pin layout. Port C4 = AD4/SDA and Port C5 = AD5/SCL.
Jee Labs has done work on an Arduino variant and uses software I2C to extend the number of I2C capable pins here http://news.jeelabs.org/2010/03/15/software-and-hardware-i2c/ and I think this http://cafe.jeelabs.net/sw/library_-_ports/ is the library that allows the JeeNode to do this. Instructions are given for adding it to the Arduino IDE.
hi Professor Chaos and capt.tagon,
Thanks alot! It's exactly what I'm looking for, bit-bang I2C.
Wait.. so can you redirect I2C to other digital pins and then use Analog_4 and Analog_5 as regular analog pins to measure voltages? Or would Analog_4 and Analog_5 still be hogtied by I2C?
If you bit banged the I2C and didn't use the internal I2C hardware then yes you could reclaim those two analogue inputs.
Just find "SoftI2CMaster.h" and its associated c - it works well.
#include <SoftI2cMaster.h>
#define SCL_PIN 9
#define SDA_PIN 8
SoftI2cMaster rtc;
#define DS1307ADDR 0XD0