// Dont Forget to Support My Channel
// Electro Pemula on Youtube and TikTok
// https://www.youtube.com/channel/UCa8eHXL2aL6lc1UN_bcge7A/
// https://www.tiktok.com/@elektropemula/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
// Inisialisasi OLED dengan I2C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
Serial.begin(115200);
// Memulai layar OLED
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Menggunakan alamat I2C OLED 0x3C
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.clearDisplay(); // Membersihkan layar
}
void loop() {
// Tampilkan teks "Hello World!"
display.setTextSize(3);
display.setTextColor(SSD1306_WHITE);
display.setCursor(20, 10);
display.print("Hello");
display.setCursor(15, 40);
display.println("World!");
display.display(); // Menampilkan teks
delay(1000); // Tunda selama 1 detik
display.clearDisplay(); // Menghapus layar untuk efek blink
delay(1000); // Tunda selama 1 detik
}