// ============ Include Library ===================
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// ============ End Include Library ===================
// ============ Define Pin ===================
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
// ============ End Define Pin ==============
// ============ Class ===================
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// ============ End Class ===================
// ============ Variabel ===================
char nama[] = "Abhinaya FL";
char nim[] = "E41212013";
char kelas[] = "IoT - 3";
byte textSize = 1; // Ukuran teks default
// ============ End Variabel ===================
// ============ Function ===================
void oled_init();
void oled_display();
// ============ End Function ===================
void setup() {
Serial.begin(9600);
oled_init();
}
void loop() {
oled_display();
delay(1000); // Delay 1 detik sebelum menampilkan ulang informasi pada layar OLED
}
void oled_init() {
if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("failed to start SSD1306 OLED"));
while (1);
}
}
void oled_display() {
oled.clearDisplay();
oled.setTextSize(textSize); // Menggunakan variabel untuk mengatur ukuran teks
oled.setTextColor(SSD1306_WHITE);
oled.setCursor(0, 0);
oled.println("Nama: ");
oled.setCursor(0, 10);
oled.println(nama);
oled.setCursor(0, 20);
oled.println("NIM: ");
oled.setCursor(0, 30);
oled.println(nim);
oled.setCursor(0, 40);
oled.println("Kelas: ");
oled.setCursor(0, 50);
oled.println(kelas);
oled.display();
}