Created
June 6, 2020 03:43
-
-
Save komponenrobot/a860ffa22f6695f13b3c80e1792b6ac8 to your computer and use it in GitHub Desktop.
oled-ssd1306-esp32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <Adafruit_SSD1306.h> // Memanggil Library OLED SSD1306 | |
#define SCREEN_WIDTH 128 // Lebar Oled dalam Pixel | |
#define SCREEN_HEIGHT 32 // Tinggi Oled dalam Pixel | |
#define OLED_RESET 4 | |
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); | |
int dataInt; //Mendeklarasi varibel dataInt | |
void setup() { | |
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // alamat I2C 0x3C untuk 128x32 | |
Serial.println(F("SSD1306 Gagal")); | |
for(;;); // mengulang terus, hingga bisa menghubungkan ke I2C Oled | |
} | |
display.display(); | |
delay(2000); | |
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("Robotik ID")); //Menampilkan Tulisan RobotikIndonesia | |
display.setCursor(0,9); // Koordinat awal tulisan (x,y) dimulai dari atas-kiri | |
display.println(dataInt); //Menampilkan nilai variabel dataInt | |
display.display(); //Mulai Menampilkan | |
delay(2000); | |
} | |
void loop(){ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment