Post
by andrew » Fri Feb 10, 2023 3:08 pm
is it possible to write to more displays in one code?
You can do this by creating two instances of the library and then assigning a different I2C address to each instance. Here is an example of how to do it:
#include "SmartLCDI2C.h" //Include the SmartLCD I2C Library
#define I2C_ADD1 0x27 //I2C address of SmartLCD 1
#define I2C_ADD2 0x28 //I2C address of SmartLCD 2
// Create two instances of the library (SmartLCD1 & SmartLCD2)
// and assign them different addresses
SmartLCD SmartLCD1(I2C_ADD1);
SmartLCD SmartLCD2(I2C_ADD2);
void setup()
{
// Initialise both instances of the library
SmartLCD1.init();
SmartLCD2.init();
// Clear both screens
SmartLCD1.Clear();
SmartLCD2.Clear();
}
void loop()
{
// Print something to each screen
SmartLCD1.Print("Hello");
SmartLCD2.Print("World !");
while(1);
}
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.