#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <avr/pgmspace.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const char table1[] PROGMEM = {"103509335"};
const char table2[] PROGMEM = {"Jadid"};
const char table3[] PROGMEM = {"ENG20009"};
const char table4[] PROGMEM = {"Engineering Technology Inquiry Project"};
const char table5[] PROGMEM = {"Semester 1"};
const char table6[] PROGMEM = {"2023"};
char myChar;
void setup() {
// Initialize the OLED display
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
Serial.println(F("SSD1306 allocation failed"));
for (;;) {} // Don't proceed, loop forever
}
// Set the text color to white
display.setTextColor(SSD1306_WHITE);
// Set the text size to fit the screen
display.setTextSize(1);
// Define the starting y-coordinate for each line of text
int yCoordinates[] = {10, 20, 30, 30, 40, 40};
// Loop through each line of text and scroll it from right to left
for (int i = 0; i < 6; i++) {
const char* table = nullptr;
// Assign the correct table based on the current line
switch (i) {
case 0:
table = table1;
break;
case 1:
table = table2;
break;
case 2:
table = table3;
break;
case 3:
table = table4;
break;
case 4:
table = table5;
break;
case 5:
table = table6;
break;
default:
break;
}
// Scroll the text from right to left
for (int j = SCREEN_WIDTH; j >= -display.getCursorX(); j--) {
display.clearDisplay();
display.setCursor(j, yCoordinates[i]);
for (int k = 0; k < strlen_P(table); k++) {
myChar = pgm_read_byte_near(table + k);
display.print(myChar);
}
display.display();
delay(1);
}
// Add a delay between each line of text
delay(100);
}
}
void loop() {
}