#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const int tombol_1 = 4;
const int tombol_2 = 3;
const int tombol_3 = 2;
const int led_merah = 12;
const int led_kuning = 11;
const int led_hijau = 10;
int i = 0;
int hitung = 100;
void setup() {
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
pinMode(tombol_1, INPUT_PULLUP);
pinMode(tombol_2, INPUT_PULLUP);
pinMode(tombol_3, INPUT_PULLUP);
pinMode(led_merah, OUTPUT);
pinMode(led_kuning, OUTPUT);
pinMode(led_hijau, OUTPUT);
//hitung = hitung/2;
while(i<=10){
hitung = hitung+2;
i=i+1;
}
}
void loop() {
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(WHITE); // Draw white text
display.setCursor(0,0); // Start at top-left corner
display.print("Budi ");
display.println("Setiawan"); // Tampilkan tulisan " ABCDEFG" kemudian ganti baris pada tex selanjutnya
display.println("0817384638");
display.println("Kelas A");
display.println(hitung);
display.display();
}