/* Arduino UNO with SSD1306 128x64 I2C OLED display * Demonstrates graphics and text elements * Tony Goodhew 26 May 2020 */ #include // Not needed with I2C #include #include #include #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels #define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); void show() { // Often used sequence - Function to simplify code display.display(); delay(2000); display.fillScreen(SSD1306_BLACK); } void setup() { // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) Serial.begin(9600); // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Old Address 0x3D for 128x64 Serial.println(F("SSD1306 allocation failed")); for(;;); // Don't proceed, loop forever } // Initialise variables int cw = SSD1306_WHITE; int cb = SSD1306_BLACK; // Title screen display.clearDisplay(); display.setTextSize(2); display.setTextColor(SSD1306_WHITE); // Draw white text display.setCursor(20,10); display.setTextSize(2); // Medium display.println("Michelle"); display.setCursor(20,25); display.println("Kim"); show(); } void loop() { // put your main code here, to run repeatedly: }