Der Vorteil eines I2C-Moduls liegt klar auf der Hand… 2 statt 5 Kabel, somit sind mehr Pins frei.
Will man mehr als ein LCD ansteuern, kein Problem….. es bleiben 2 Kabel 🙂
Board I2C an pin:
Uno, Nano, Ethernet A4 (SDA), A5 (SCL)
Mega2560 20 (SDA), 21 (SCL)
Leonardo 2 (SDA), 3 (SCL)
Due 20 (SDA), 21 (SCL), SDA1, SCL1
#include
#include
LiquidCrystal_I2C lcd1(0x27,2,1,0,4,5,6,7); // 0x27 is the I2C bus address for an unmodified backpack
LiquidCrystal_I2C lcd2(0x20,2,1,0,4,5,6,7); // 0x27 is the I2C bus address for an unmodified backpack
void setup()
{
// activate LCD 1 module
lcd1.begin (16,2); // for 16 x 2 LCD module
lcd1.setBacklightPin(3,POSITIVE);
lcd1.setBacklight(HIGH);
// activate LCD 2 module
lcd2.begin (16,2); // for 16 x 2 LCD module
lcd2.setBacklightPin(3,POSITIVE);
lcd2.setBacklight(HIGH);
}
void loop()
{
lcd1.home (); // set cursor to 0,0
lcd2.home (); // set cursor to 0,0
lcd1.print("LCD 1");
lcd2.print("LCD 2");
lcd1.setCursor (0,1); // go to start of 2nd line
lcd1.print(millis());
lcd2.setCursor (0,1);
lcd2.print(millis());
delay(1000);
}