/*------------------------------------------------------------------------------------- * Template file for 4-pin I2C OLED display, e.g. from Geekcreit * using Adafruit SSD1306 driver and GFX libraries. * Tutorial: * https://startingelectronics.org/tutorials/arduino/modules/OLED-128x64-I2C-display/ *-------------------------------------------------------------------------------------*/ #include #include #include // OLED display TWI address #define OLED_ADDR 0x3C Adafruit_SSD1306 display(-1); #if (SSD1306_LCDHEIGHT != 64) #error("Height incorrect, please fix Adafruit_SSD1306.h!"); #endif void setup() { // initialize and clear display display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR); display.clearDisplay(); display.display(); // display a pixel in each corner of the screen display.drawPixel(0, 0, WHITE); display.drawPixel(127, 0, WHITE); display.drawPixel(0, 63, WHITE); display.drawPixel(127, 63, WHITE); // display a line of text display.setTextSize(3); display.setTextColor(WHITE); display.setCursor(7,3); display.print("Hello"); display.setCursor(7,40); display.print("world!"); // update display with all of the above graphics display.display(); } void loop() { // put your main code here, to run repeatedly: }