Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Arduino
50 min
Share

How to display text on OLED display with Arduino

OLED displays are becoming increasingly popular. When combined with an Arduino microcontroller, these displays can be used to create a wide range of projects that require a compact and low-power display.

Project Video

Overview

In this tutorial, we will explain how to operate an OLED display using Arduino. You will learn to display a string like your name or a pre-defined message. Also, after completing this tutorial, you will be able to display any variable or pixel as per your requirement.

Getting the Items

Arduino Uno R3 (Voltaat Version)
Get Item
White OLED Display Screen
Get Item
Jumper Wires - Male to Male (40 Pack)
Get Item

Steps

Wiring it Up

Connect the wires between the OLED Display and the Arduino as shown in the on the image below.

Connections from the OLED Display to arduino :

  • OLED VCC PIN → Arduino 5V pin
  • OLED GND PIN → Arduino GND pin
  • OLED SDA PIN → Arduino pin A4
  • OLED SCL PIN → Arduino pin A5

Coding


/*
Voltaat learn (http://learn.voltaat.com)
Link for full tutorial:

Wire library
Adafruit_GFX library
Adafruit_SSD1306 library

Tutorial: How to display text on OLED display with Arduino!

The function of this sketch is to display some words and variables on the OLED display screen.
You can print your name on the screen and print some dots on the screen in different pixels,
which enables you to draw curves later.


Connections from the OLED Display to arduino :

OLED VCC PIN → Arduino 5V pin


OLED GND PIN → Arduino GND pin


OLED SDA PIN → Arduino pin A4


OLED SCL PIN → Arduino pin A5

*/

#include "SPI.h"
#include "Wire.h"
#include "Adafruit_GFX.h"
#include "Adafruit_SSD1306.h"

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
int a=1; // global variable

void setup()   {  
 Serial.begin(9600);

 // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
 display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x64)
 

 display.clearDisplay(); // Clear the buffer.

 
 display.setTextSize(2); // You can select text size ex- 1, 2, 3 and so on
 display.setTextColor(WHITE); // This will display Bright character on Black background
 display.setCursor(5,0); // You are setting the cursor as per your requirement. In short its the co-ordinates in display from where data will display
 display.println("voltaat"); // String which you are printing

 display.setTextSize(1);
 display.setTextColor(BLACK, WHITE); // Here you print 'Black character' on 'Bright Background'
 display.setCursor(12,25);
 display.println("www.voltaat.com");

 display.setTextSize(3);
 display.setTextColor(WHITE);
 display.setCursor(13,44);
 display.println("voltaat team");
 
 display.display(); // this command will display all the data which is in buffer
 delay(2000);
 
 display.clearDisplay(); // clear the buffer
 
}

void loop() {
 display.clearDisplay();
 if(a>10){a=0;} // This loop will make counter 0 again after reaching maximum value 10
 display.drawPixel(127, 63, WHITE); // This command will help you to print a pixel on display , its the last pixel, coordinate 127,63
 display.drawPixel(0, 0, WHITE); // pixel with 0,0 coordinate
 display.setTextSize(3);
 display.setTextColor(WHITE);
 display.setCursor(13,44);
 display.println("voltaat");
 display.setCursor(10,0);
 display.setTextSize(2);
 display.println(a); // printing a variable
 a++; // incriment in variable a
 display.display();
 delay(1000);
}

   
   

Testing it Out

Once you’ve uploaded the code to the Arduino board, you will find that the OLED Display displays some words and variables.

Resources

No items found.