#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
Serial.begin(9600);
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
delay(2000);
display.clearDisplay();
}
void loop() {
String text_to_scroll = "Chinesium ";
int buffer_size = SCREEN_WIDTH * 2;
String buffer_text = "";
for (int i = 0; i < buffer_size / text_to_scroll.length(); i++) {
buffer_text += text_to_scroll;
}
while(true) {
for(int i = 0; i < buffer_text.length() - SCREEN_WIDTH; i++) {
display.clearDisplay();
display.setTextSize(8);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0, 0);
display.print(buffer_text.substring(i, i + SCREEN_WIDTH));
display.display();
delay(100);
}
}
}