I found that this code appears to light up all 3 OLED displays, however each OLED display reads 'One', instead of their respective number. I'm not sure if my addressing is incorrect or not. How could I change this code to display 'One', 'Two' and 'Three' to their respective OLED display?
#include "U8g2lib.h"
#include "Wire.h" //Library for I2C interface
U8G2_SH1106_128X64_NONAME_F_HW_I2C OLED_1(U8G2_R0, U8X8_PIN_NONE);
U8G2_SH1106_128X64_NONAME_F_HW_I2C OLED_2(U8G2_R0, U8X8_PIN_NONE);
U8G2_SH1106_128X64_NONAME_F_HW_I2C OLED_3(U8G2_R0, U8X8_PIN_NONE);
void setup() {
OLED_1.setI2CAddress(0x3C * 2);
OLED_2.setI2CAddress(0x3D * 2);
OLED_3.setI2CAddress(0x7A * 2);
OLED_1.begin();
OLED_2.begin();
OLED_3.begin();
OLED_1.setFont(u8g_font_6x10);
OLED_2.setFont(u8g_font_6x10);
OLED_3.setFont(u8g_font_6x10);
}
void loop() {
static unsigned long oledTimer = millis(); //every 1000ms update the oled display
if (millis() - oledTimer >= 1000) {
oledTimer = millis();
drawOLED_1();
drawOLED_2();
drawOLED_3();
}
}
void drawOLED_1(void) {
char buffer[10];
OLED_1.clearBuffer(); // clear the internal memory
OLED_1.setFont(u8g_font_6x10);
OLED_1.drawStr(0, 10, "One");
OLED_1.drawStr(80, 10, buffer);
OLED_1.sendBuffer(); // transfer internal memory to the display
}
void drawOLED_2(void) {
char buffer[10];
OLED_2.clearBuffer(); // clear the internal memory
OLED_2.setFont(u8g_font_6x10);
OLED_2.drawStr(0, 10, "Two");
OLED_2.drawStr(80, 10, buffer);
OLED_2.sendBuffer(); // transfer internal memory to the display
}
void drawOLED_3(void) {
char buffer[10];
OLED_3.clearBuffer(); // clear the internal memory
OLED_3.setFont(u8g_font_6x10);
OLED_3.drawStr(0, 10, "Three");
OLED_3.drawStr(80, 10, buffer);
OLED_3.sendBuffer(); // transfer internal memory to the display
}