#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <EEPROM.h>
#include <Fonts/FreeMonoBold9pt7b.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// Define the address of the EEPROM component
#define EEPROM_ADDR 0x50
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.display();
delay(2000);
display.clearDisplay();
// font size to 1 and font to FreeMonoBold9pt7b
display.setTextSize(0.2);
display.setFont(&FreeMonoBold9pt7b);
// text color to white
display.setTextColor(SSD1306_WHITE);
// Write student ID to EEPROM
char studentID[] = "103798625";
for (int i = 0; i < sizeof(studentID); i++) {
EEPROM.write(i, studentID[i]);
}
EEPROM.write(sizeof(studentID), '\0'); // Null-terminate the string
// Display student ID from EEPROM on OLED
display.print("\nStudent ID:\n");
for (int i = 0; i < sizeof(studentID); i++) {
char c = EEPROM.read(i);
if (c == '\0') break;
display.print(c);
}
display.display();
delay(1000);
}
void loop() {
display.startscrollleft(0x00, 0x0F); // Scroll display to the left
delay(1000);
}