Introduction
In this tutorial, we are going to learn how to interface with an OLED Display. Also, we will discuss OLED Display.
Theory
OLED Display is briefly known as Organic Light Emitting Diode.
It has a self-light-emitting technology composed of a thin, multi-layered organic film placed between an anode and cathode.
It is a display of 0.96 inches and a resolution of 128*64.
It didn't require a backlight.
It works on the I2C communication protocol.
It has 4 pins,
i)VCC
ii)GND
iii)SCK (Serial Clock)
iv)SDA (Serial Data)
Parts Required
Parts | Quantity |
Arduino UNO | 1 |
A-B cable | 1 |
OLED Display | 1 |
Bread Board | 1 |
Connecting Wires | As per required |
Circuit Diagram
Code
For programming this concept we need to understand some basic syntax of Arduino IDE. The first thing is we need to install Arduino.
After installing you need to add some libraries.
Go to Sketch>Include Library>Manage Libraries...
Then search Adafruit_GFX.h , Adafruit_SSD1306.h , and add it.
You can also download it from the link.
After installation, all libraries call the libraries.
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
After calling, go for the void setup function.
In this, we will write how to show data in the display.
void setup()
{
// initialize with the I2C addr 0x3C
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
// Clear the display.
display.clearDisplay();
// Display Text
display.setTextSize(1); // size of text
display.setTextColor(WHITE); // text color
display.setCursor(0,28); // set the cursor
display.println("Welcome to Robogenesis"); // text
display.display(); // function for display
delay(2000);
display.clearDisplay(); // after display clear the text
}
Here no need for a void loop function, so only write it simply.
Final Code
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display(-1);
void setup()
{
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(0,28);
display.println("Welcome to Robogenesis");
display.display();
delay(2000);
display.clearDisplay();
}
void loop()
{
}
Comments