#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
#define SCREEN_ADRESS 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup(){
Serial.begin(115200);
// Initialize OLED Object
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADRESS)){
Serial.println(F("SSD1306 allocation failed"));
for(;;)
{
}
}
display.clearDisplay();
}
void loop(){
// display Text
display.setTextSize(1); //set font size to 1
display.setTextColor(WHITE); // set colour to white
display.setCursor(0,28);
display.println(123456789);
display.display(); //update the display
delay(2000);
display.clearDisplay();
// specifying the base for Numbers
display.setCursor(0,28);
display.print("0x");
display.print(0xFF, HEX); // Print the number in hexadecimal
display.print("(HEX) = ");
display.print(0xFF, DEC);
display.print("(DEC)");
display.display();
delay(2000);
display.clearDisplay();
display.setCursor(0,28);
display.print("0b");
display.print(0b01101101, BIN); // Print the number in hexadecimal
display.print("(BIN) = ");
display.print(0b01101101, DEC);
display.print("(DEC)");
display.display();
delay(2000);
display.clearDisplay();
}