Postion:Home > OLED Display technology

OLED Display technology

0.96 inch SSD1306 Oled Arduino application tuitorial

We are introducing the 0.96" oled screen that with 4 pins connection, it is SSD1306 oled display, that means it is the oled display module with SSD1306 IC driver. The oled display module is composed with oled display panel, IC driver, flex cable (FPC), sometimes with PCB behind the oled display panel,

The 0.96” Adafruit SSD1306 oled display is designed that easily to connect with Arduino board. one power supply (+5V), it has been in-bulit DC-DC on board,  IIC interface that can be connected directly to Arduino by pin to pin. We would provide the SSD1306 library as well.

How do I use Oled SSD1306? please check the following steps:

1.     How do I connect OLED display to Arduino Uno?

Because the 0.96" SSD1306 OLED display uses I2C communication port, wiring is very simple. You just need to connect to the Arduino Uno I2C pins as shown in the table below.

Pin

Wiring to Arduino Uno

Vin

5V

GND

GND

SCL

A5

SDA

A4

If you’re using a different Arduino board, make sure you check the correct I2C pins:

  • Nano: SDA (A4); SCL (A5);
  • MEGA: SDA (20); SCL (21);
  • Leonardo: SDA (20); SCL (21);

0.96 inch SSD1306 OLED Arduino


2.  How do I use adafruit SSD1306 Libraries?

To control the OLED display you need the adafruit_SSD1306.h and the adafruit_GFX.h libraries. Follow the next instructions to install those libraries.

1. Open your Arduino IDE and go to Sketch > Include Library > Manage Libraries. The Library Manager should open.

SSD1306 OLED-1


2. Type “SSD1306” in the search box and install the SSD1306 library from Adafruit.

SSD1306 OLED-2

3. After installing the SSD1306 library from Adafruit, type “GFX” in the search box and install the library.

you could also choose " install all" button here.

SSD1306-3



4. After installing the libraries, restart your Arduino IDE. open Adafruit_SSD1306 libraries "examples".

Choose the SSD1306_128X64_I2C for 0.96" OLED.

SSD1306-4


Tips for writing text using these libraries

Here’s some functions that will help you handle the OLED display library to write text or draw simple graphics.

  • display.clearDisplay() – all pixels are off
  • display.drawPixel(x,y, color) – plot a pixel in the x,y coordinates
  • display.setTextSize(n) – set the font size, supports sizes from 1 to 8
  • display.setCursor(x,y) – set the coordinates to start writing text
  • display.print(“message”) – print the characters at location x,y
  • display.display() – call this method for the changes to make effect

Testing the OLED Display

After wiring the OLED display to the Arduino and installing all required libraries, you can use one example from the library to see if everything is working properly.

In your Arduino IDE, go to File > Examples > Adafruit SSD1306 and select the example for the display you’re using.


The following code should be loaded:

If your OLED display module doesn’t have a RESET pin, you should set the OLED_RESET variable to -1 as shown below:

#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)


Upload the code to your Arduino board. Don’t forget to select the right board and COM port in the Tools menu.

You should get a series of different animations in the OLED as shown in the following short video.


If your OLED display is not showing anything:

  • Check that the OLED display is properly wired to the Arduino
  • Double-check the OLED display I2C address: with the OLED connected to the Arduino, upload this code and check the I2C address in the Serial Monitor

You should change the OLED address in the following line, if necessary. In our case, the address is 0x3C.

if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {

Write Text – OLED Display

The Adafruit library for the OLED display comes with several functions to write text. In this section, you’ll learn how to write and scroll text using the library functions.

“Hello, world!” OLED Display

The following sketch displays "Hello, world!" message in the OLED display.

// Scroll in various directions, pausing in-between:
display.startscrollright(0x00, 0x0F);
delay(2000);
display.stopscroll();
delay(1000);
display.startscrollleft(0x00, 0x0F);
delay(2000);
display.stopscroll();
delay(1000);
display.startscrolldiagright(0x00, 0x07);
delay(2000);
display.startscrolldiagleft(0x00, 0x07);
delay(2000);
display.stopscroll();
delay(1000);
}
void testdrawbitmap(void) {
display.clearDisplay();
display.drawBitmap(
(display.width()  - LOGO_WIDTH ) / 2,
(display.height() - LOGO_HEIGHT) / 2,
logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);
display.display();
delay(1000);
}
#define XPOS   0 // Indexes into the 'icons' array in function below
#define YPOS   1
#define DELTAY 2
void testanimate(const uint8_t *bitmap, uint8_t w, uint8_t h) {
int8_t f, icons[NUMFLAKES][3];
// Initialize 'snowflake' positions
for(f=0; f< NUMFLAKES; f++) {
icons[f][XPOS]   = random(1 - LOGO_WIDTH, display.width());
icons[f][YPOS]   = -LOGO_HEIGHT;
icons[f][DELTAY] = random(1, 6);
Serial.print(F("x: "));
Serial.print(icons[f][XPOS], DEC);
Serial.print(F(" y: "));
Serial.print(icons[f][YPOS], DEC);
Serial.print(F(" dy: "));
Serial.println(icons[f][DELTAY], DEC);
}
for(;;) { // Loop forever...
display.clearDisplay(); // Clear the display buffer
// Draw each snowflake:
for(f=0; f< NUMFLAKES; f++) {
display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, WHITE);
}
display.display(); // Show the display buffer on the screen
delay(200);        // Pause for 1/10 second
// Then update coordinates of each flake...
for(f=0; f< NUMFLAKES; f++) {
icons[f][YPOS] += icons[f][DELTAY];
// If snowflake is off the bottom of the screen...
if (icons[f][YPOS] >= display.height()) {
// Reinitialize to a random position, just off the top
icons[f][XPOS]   = random(1 - LOGO_WIDTH, display.width());
icons[f][YPOS]   = -LOGO_HEIGHT;
icons[f][DELTAY] = random(1, 6);
}
}
}
}


Here comes the display:

SSD1306 OLED I2C 0.96 inch



Download SSD1306 datasheet here ==> SSD1306 datasheet (szmaclight.com)

Buy the 0.96" oled 128x64 here ==> 0.96 inch oled display I2C interface 128x64 SSD1306 for Arduino (szmaclight.com)

CATEGORIES

CONTACT US

Tel: +86-755-27205930

Email: [email protected]

Add: No.205,A Zone,Mingyou Purchasing center,Baoyuan Road,Baoan District,Shenzhen,China