Project 011: Arduino 1.3" I2C White OLED Display Project

Project 011: Arduino 1.3" I2C White OLED Display Project © GPL3+

This beginner Arduino project using an OLED display is perfect for any graphical projects or projects involving visuals of data or images.

  • 12,656 views
  • 2 comments
  • 1 respect

Components and supplies

1.3'' i2c White OLED
×1
Ph a000066 iso (1) ztbmubhmho
Arduino UNO
You could use any other Arduino board as well. The Seeeduino v4.2 is used in this example.
×1
11026 02
Jumper wires (generic)
4 Male to Female Jumper Wires.
×4
Adafruit industries ada62 image 75px
USB-A to B Cable
Depends on the Arduino.
×1
NextPCB
×1

Apps and online services

About this project

Before starting this project...

I am absolutely sure that you will find this OLED (Omitting Light Emitting Diode) project useful in the future. With this OLED display, it is much easy to feature texts, visuals, graphics or even animations, plus, any sensor's readings can be displayed to this OLED for a more portable, convenient use. An OLED consists of many miniature pixels, in which each one is programmed individually from its driver chip. Each pixel tends to draw a certain amount of current, so there is no set operating current with this display and it could vary vastly, also, there is no backlight on this module as each pixel makes its own light already. There is not a need for any sort of level shifter required for using this board and it can connect to your microcontroller directly, running on the i2c interface. Anyways, for this project, the components you will need include:

  • 1 1.3" i2c White OLED Display
  • 1 Arduino (the Seeeduino v4 is used in this example)
  • 4 Jumper Wires (Male to Female)
  • 1 USB Data Cable (depends on the Arduino)

Please visit this link here for NextPCB's special offers.

Mounting the circuit

Note: Look at the pinout of the OLED display in the diagram and of your OLED display. It may be different like in this case, as the pictures above and the diagram above has different pinout orders from the left. You can follow the schematics for pin-to-pin wiring.

Since this i2c OLED display runs on the i2c protocol, it only require a simple, four connection wiring. This wiring could be used in, practically any i2c device as it all follows the same interface. Before starting, remove any power sources going through the Arduino and the circuit, as it can be a safety hazard. Let's now get started by using the Male to Female jumper wires for the connections because no breadboards are needed. First, use one of the wires to connect GND (-) on the OLED to anyone of your Arduino's GND (-) pins. Secondly, connect the VCC (+) pin of your 1.3" OLED to the 5v (+5 volts) pin on your Arduino. Consecutively, connect the SCL (serial clock) pin from the display to A5 (analog pin 5) on your Arduino, as well as connecting the SDA (serial data) pin to A4 (analog pin 4) on your Arduino. That wraps up your wiring for this module!

About the code

At first glance, this code may seem complex and difficult for some, but, after we break it down into smaller parts and we really get to understand the code functions, it won't seem so intimidating anymore. First, this code starts with declaring a library we will be using, the U8glib library, which helps us to operate the OLED being used. The U8glib library supports many display types, with different resolutions and drivers, like the SH1106 driver or the SSD1306 driver. After that line of code, a constructor is outlined where it defines the OLED used. The constructor, word-by-word in this case, means that it uses the U8glib library, runs on the SH1106 driver, has a 128x64 pixel resolution, and it doesn't require an optimisation. The constructors (which you can take from the library page) must match your display. Moving on, we now declare a void statement, a section which we can execute to the display later. This section is named draw. In this statement, the font for the OLED text is assigned which is the profont12 font. The types of fonts can be found in the U8glib home page. After that, the position for the text is set, which is (0, 10) on the pixel display with dimensions of 128 pixels and 64 pixels. Then, the text is written, in order for it to be displayed. This same concept of declaring the position of the text and printing the text is repeated twice with the text being varied in this void block. The repeated lines now end this void statement. The following block of code (void draw2) follows the exact same concept mentioned above, except, the name of the block is changed and we add in another line of code which changes the font for one string we want to print. We change the font to a smaller font,  profont10, and it only applies to the next string (u8g.print("electorials.weebly.com.");) as we change it back to profont12 in the loop of the void statement because of the redeclaration of the font. Next up comes the void setup of the sketch, where nothing is done because no necessary, additional setup is needed to this program. Finally, the void loop arrives, as the last section to this code. There is a small declaration of the phrase u8g.firstPage(); and we assign it to the void draw statement earlier. That will be printed while we get ready for the next, incoming page with u8g.nextPage(); under a while function. So when the first page is being printed, the next page will get ready after the 3500 millisecond delay in the delay function. This idea is also followed next with the printing of the void draw2 statement instead followed by a 3500 millisecond delay for each phrase. That is it for this long; yet simple piece of code!

Amazing opportunities

UTSource.net Reviews

It is a trustworthy website for ordering electronic components with cheap price and excellent quality.

Also, be sure to check out PCBWay, a leading manufacturer and distributor in PCB design and manufacturing. They have amazing prices and excellent quality in their services, so don't miss out on them! Plus, PCBWay has an amazing website, online Gerber viewer function and a gift shop so make sure to check out their links below:

PCBWay Free Online Gerber Viewer Function: https://www.pcbway.com/project/OnlineGerberViewer.html

PCBWay Gift Shop: https://www.pcbway.com/project/gifts.html

Make sure you check out the review for this meter by clicking here.

Enjoy! Contact us for any inquiries!

Code

Arduino 1.3" i2c White OLED Display Project CodeC/C++
#include "U8glib.h"
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE);

void draw(void) {
  u8g.setFont(u8g_font_profont12);
  u8g.setPrintPos(0, 10);
  u8g.print("This is the 1.3\"");
  u8g.setPrintPos(0, 25);
  u8g.print("White i2c OLED from");
  u8g.setPrintPos(0, 40);
  u8g.print("ICStation.com.");
}

void draw2(void) {
  u8g.setFont(u8g_font_profont12);
  u8g.setPrintPos(0, 10);
  u8g.print("Check out the project");
  u8g.setPrintPos(0, 25);
  u8g.print("and review on");
  u8g.setPrintPos(0, 40);
  u8g.setFont(u8g_font_profont10);
  u8g.print("electorials.weebly.com.");
}

void setup(void) {
}

void loop(void) {
  u8g.firstPage();
  do {
    draw();
  } while (u8g.nextPage() );
  delay(3500);
  u8g.firstPage();
  do {
    draw2();
  } while (u8g.nextPage());
  delay(3500);
}

Schematics

Circuit Diagram
Seeed crjoxuj6qh
Schematics
Seeed2 u8cgoybtbt

Comments

Similar projects you might like

I2C OLED Display Using Arduino/NodeMCU

by Tarantula3

  • 40,090 views
  • 3 comments
  • 42 respects

Control a 7 Segment Display with a keypad!

Project tutorial by Isaac100

  • 31,267 views
  • 21 comments
  • 37 respects

GPS Location Display With GPS And TFT Display Shields

Project tutorial by Boian Mitov

  • 28,208 views
  • 8 comments
  • 42 respects

Arduino Pong Game - OLED Display

Project tutorial by Nick Koumaris

  • 24,857 views
  • 3 comments
  • 31 respects

TM1637 Digit Display - Arduino Quick Tutorial

by Ryan Chan

  • 24,084 views
  • 5 comments
  • 8 respects
Add projectSign up / Login