#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // Lebar Oled dalam Pixel
#define SCREEN_HEIGHT 64 // Tinggi Oled dalam Pixel
#define OLED_RESET 4
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const unsigned char logoELITE[] PROGMEM = {
0xff, 0xff, 0xf8, 0x7c, 0x00, 0x00, 0xf8, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
0xff, 0xff, 0xf8, 0x7c, 0x00, 0x00, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
0xff, 0xff, 0xf8, 0x7c, 0x00, 0x00, 0xf8, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
0xff, 0xff, 0xf8, 0x7c, 0x00, 0x00, 0xf8, 0x07, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
0xff, 0xff, 0xf8, 0x7c, 0x00, 0x00, 0xf8, 0x03, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
0xf8, 0x00, 0x00, 0x7c, 0x00, 0x00, 0xf8, 0x00, 0x01, 0xf0, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00,
0xf8, 0x00, 0x00, 0x7c, 0x00, 0x00, 0xf8, 0x00, 0x01, 0xf0, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00,
0xf8, 0x00, 0x00, 0x7c, 0x00, 0x00, 0xf8, 0x00, 0x01, 0xf0, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00,
0xf8, 0x00, 0x00, 0x7c, 0x00, 0x00, 0xf8, 0x00, 0x01, 0xf0, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00,
0xff, 0xff, 0xf8, 0x7c, 0x00, 0x00, 0xf8, 0x00, 0x01, 0xf0, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
0xff, 0xff, 0xf8, 0x7c, 0x00, 0x00, 0xf8, 0x00, 0x01, 0xf0, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
0xff, 0xff, 0xf8, 0x7c, 0x00, 0x00, 0xf8, 0x00, 0x01, 0xf0, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
0xff, 0xff, 0xf8, 0x7c, 0x00, 0x00, 0xf8, 0x00, 0x01, 0xf0, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
0xff, 0xff, 0xf8, 0x7c, 0x00, 0x00, 0xf8, 0x00, 0x01, 0xf0, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
0xf8, 0x00, 0x00, 0x7c, 0x00, 0x00, 0xf8, 0x00, 0x01, 0xf0, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00,
0xf8, 0x00, 0x00, 0x7c, 0x00, 0x00, 0xf8, 0x00, 0x01, 0xf0, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00,
0xf8, 0x00, 0x00, 0x7c, 0x00, 0x00, 0xf8, 0x00, 0x01, 0xf0, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00,
0xf8, 0x00, 0x00, 0x7c, 0x00, 0x00, 0xf8, 0x00, 0x01, 0xf0, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0xf8, 0x00, 0x01, 0xf0, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xf8, 0x00, 0x01, 0xf0, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0xf8, 0x00, 0x01, 0xf0, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0xf8, 0x00, 0x01, 0xf0, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xf8, 0x00, 0x01, 0xe0, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x89, 0x8a, 0x56, 0xa8, 0xa8, 0xea, 0xaa, 0x51, 0x56, 0xa2, 0xa6, 0xb4, 0x58, 0x00, 0x00, 0x00,
0xe9, 0xd0, 0x1d, 0x0c, 0xa0, 0xeb, 0xa4, 0x08, 0x52, 0xa4, 0x36, 0x97, 0x70, 0x00, 0x00, 0x00,
0x89, 0x10, 0x15, 0x2a, 0xa0, 0xdb, 0xa5, 0xb8, 0x52, 0x64, 0x05, 0x94, 0x50, 0x00, 0x00, 0x00,
0xee, 0xcc, 0x12, 0xea, 0xb8, 0xca, 0xb9, 0xa0, 0x5c, 0x23, 0x3c, 0x97, 0x48, 0x00, 0x00, 0x00
};
bool tambah, kurang, selanjutnya, sebelumnya;
int angka, halaman = 0;
bool click, enter = false;
int page = 1;
void setup() {
pinMode(A0, INPUT_PULLUP);
pinMode(A1, INPUT_PULLUP);
pinMode(A2, INPUT_PULLUP);
pinMode(A3, INPUT_PULLUP);
Serial.begin(9600);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3D)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
// Clear the buffer
display.clearDisplay();
}
void home() {
display.clearDisplay(); //Membersihkan tampilan
display.setTextSize(1); //Ukuran tulisan
display.setTextColor(WHITE); //Warna Tulisan
display.setCursor(35,0); // Koordinat awal tulisan (x,y) dimulai dari atas-kiri
display.println(F("[ ELITE ]")); //Menampilkan Tulisan RobotikIndonesia
display.setCursor(12,15); // Koordinat awal tulisan (x,y) dimulai dari atas-kiri
display.println("Proyek Aplikasi Berbasis Sistem Menu");
display.setCursor(45,35);
if(click) {
display.setTextColor(BLACK, WHITE);
display.println("Plan?"); //Menampilkan nilai variabel dataInt
} else {
display.setTextColor(WHITE);
display.println("Plan?"); //Menampilkan nilai variabel dataInt
}
display.display(); //Mulai Menampilkan
}
void pageTwo() {
if(sebelumnya == false && click == true) {
enter = false;
click = false;
page = 1;
home();
}
display.clearDisplay(); //Membersihkan tampilan
display.setTextSize(1); //Ukuran tulisan
display.setTextColor(SSD1306_WHITE); //Warna Tulisan
display.setCursor(0,0); // Koordinat awal tulisan (x,y) dimulai dari atas-kiri
display.println(F("HALAMAN 2")); //Menampilkan Tulisan RobotikIndonesia
display.display(); //Mulai Menampilkan
}
void loop() {
tambah = analogRead(A0);
kurang = analogRead(A1);
sebelumnya = analogRead(A2);
selanjutnya = analogRead(A3);
if(page == 1) {
home();
if(tambah == false) {
click = true;
} else if(kurang == false) {
click = false;
}
if(selanjutnya == false && click == true) {
enter = true;
page = 2;
} else if(sebelumnya == false && click == true) {
enter = false;
click = false;
page = 1;
home();
}
}
if(page == 2) {
pageTwo();
}
}