Arduino – Print Text to OLED Screen

OLED Screens are great ways to display text from your Arduino Projects. You can change Font Sizes, positions and much more.

Libraries Required for this Demonstration:

  • Adafruit SSD1306
  • Adafruit GFX

Note: Remember to change the I2C address within the example sketch.

Functional Parts in the Project:

#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>

#define OLED_WIDTH 128
#define OLED_HEIGHT 64

#define OLED_ADDR   0x3C

Adafruit_SSD1306 display(OLED_WIDTH, OLED_HEIGHT);

void setup() {
  display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
  display.clearDisplay();

  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.println("Welcome");

  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0, 17);
  display.println("This is");
  display.println("a Splash");
  display.println("Screen");

  display.display();

  delay(5000);
}

void loop() {
  display.clearDisplay();

  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0, 0);
  display.println("Net Test");

  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0, 17);
  display.println("IP: 192.168.1.1");
  display.println("Subnet: 255.255.255.0");
  display.println("Gateway: 192.168.1.1");
  display.println("DNS1 : 192.168.1.2");
  display.println("DNS2: 192.168.1.3");

  display.display();
  delay(5000);
}

Be the first to comment

Leave a Reply