#include #include // IMPORTANT: Changed the last parameter from 15 to U8X8_PIN_NONE. // This prevents the library from resetting the first display when initializing the second. U8G2_SSD1320_160X132_F_4W_SW_SPI lcd1(U8G2_R0, /* clock=*/18, /* data=*/23, /* cs=*/4, /* dc=*/2, /* reset=*/U8X8_PIN_NONE); U8G2_SSD1320_160X132_F_4W_SW_SPI lcd2(U8G2_R2, /* clock=*/18, /* data=*/23, /* cs=*/5, /* dc=*/2, /* reset=*/U8X8_PIN_NONE); int x_pos = 160; // Start position (off-screen right) void setup(void) { // 1. Manually reset BOTH displays ONCE at startup pinMode(15, OUTPUT); digitalWrite(15, LOW); delay(10); digitalWrite(15, HIGH); delay(10); // 2. Initialize BOTH displays. // Because we used U8X8_PIN_NONE, this will NOT toggle the reset pin again. lcd1.begin(); lcd2.begin(); // Set a large, readable font for both lcd1.setFont(u8g2_font_10x20_tr); lcd2.setFont(u8g2_font_10x20_tr); } void loop(void) { // ========================================== // 1. Draw and send to LCD 1 (Left Half / CS Pin 4) // ========================================== lcd1.clearBuffer(); lcd1.drawStr(x_pos, 60, "Hello World!"); lcd1.sendBuffer(); // Activates CS pin 4 and updates the screen // Small delay to visually prove the CS pins are separated and working independently // delay(30); // ========================================== // 2. Draw and send to LCD 2 (Right Half / CS Pin 5) // ========================================== lcd2.clearBuffer(); // Seamless 320px scrolling: subtract 160 so it flows smoothly from the right screen into the left screen lcd2.drawStr(x_pos - 160, 60, "Hello World!"); lcd2.sendBuffer(); // Activates CS pin 5 and updates the screen // Move the text to the left for the next frame x_pos -= 2; // Reset position when it goes completely off the left side if (x_pos < -120) { x_pos = 160; } delay(2); // Control animation speed }