// Example of a software I2C bus with shared SCL
//
// Not a serious project (but it could be a crazy info panel).
//
// Code from examples:
// https://wokwi.com/arduino/projects/307841659182252608
// by Koepel
//
// https://wokwi.com/arduino/projects/307849131382014528
// by sutaburosu
#include <SoftwareWire.h>
#include "LiquidCrystal_I2C.h"
// Create three software I2C buses
SoftwareWire wire[] = {
SoftwareWire(10, SCL),
SoftwareWire(9, SCL),
SoftwareWire(8, SCL),
};
// Create an object for each LCD display
LiquidCrystal_I2C lcd[] = {
LiquidCrystal_I2C(&wire[0], 0x27, 16, 2),
LiquidCrystal_I2C(&wire[0], 0x3F, 16, 2),
LiquidCrystal_I2C(&wire[1], 0x27, 16, 2),
LiquidCrystal_I2C(&wire[1], 0x3F, 16, 2),
LiquidCrystal_I2C(&wire[2], 0x27, 16, 2),
LiquidCrystal_I2C(&wire[2], 0x3F, 16, 2),
};
constexpr auto lcd_count = sizeof(lcd) / sizeof(lcd[0]);
void setup() {
for (uint8_t screen = 0; screen < lcd_count; screen++) {
lcd[screen].init();
lcd[screen].backlight();
lcd[screen].setCursor(0, 0);
lcd[screen].print("Info Painel ");
lcd[screen].print(screen);
}
}
void loop() {
static uint16_t pos = 0;
uint8_t screen = (pos / 64) * 2 + ((pos / 16) & 1);
uint8_t column = pos % 16;
uint8_t row = (pos / 32) & 1;
screen %= lcd_count;
lcd[screen].setCursor(column, row);
lcd[screen].print(char(pos));
pos++;
}