I'm new to arduino and I'm struggling how to use another i2c device. I can use my LCD and DS1307 RTC very well on analog pins A4 and A5 one at a time.
but I cannot get it working to display time on the LCD 16x2. because A4 and A5 was already occupied by RTC.
so I started using this Library called softi2cMaster to emulate digital pins 4 and 5 as another SCl and SDA pins. these are the codes to scan the address of i2c device plugged on digital 4 and 5. it works. now I want to display time on my LCD I dont know how. ![]()
here's the Library link: > Arduino Playground - SoftwareI2CLibrary
#define SDA_PORT PORTD
#define SDA_PIN 4
#define SCL_PORT PORTD
#define SCL_PIN 5
#define I2C_TIMEOUT 100
#define I2C_FASTMODE 1
#include <SoftWire.h>
SoftWire Wire = SoftWire();
void setup()
{
Wire.begin();
Serial.begin(9600);
while (!Serial);
Serial.println("\nI2C Scanner");
}
void loop()
{
byte error, address;
int nDevices;
Serial.println(F("Scanning I2C bus (7-bit addresses) ..."));
nDevices = 0;
for(address = 1; address < 127; address++ )
{
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
Serial.print(F("I2C device found at address 0x"));
if (address<16)
Serial.print(F("0"));
Serial.print(address,HEX);
Serial.println(F(" !"));
nDevices++;
}
else if (error==4)
{
Serial.print(F("Unknow error at address 0x"));
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");
delay(5000);
}
I know this code is just another form of wire.h but at least, I was able to detect the LCD on digital pins 4 and 5.
can someone please give me a tip on how to display anything on my i2c LCD plugged on Digital pin 4 and 5 or any other than analog A4 and A5.