Information on how to use an 0.96 inch OLED Display (128*64 pixels) with an Arduino. This is an i2c module, which makes it easy to connect as it has only 4 wires. It is assumed you have installed the Arduino IDE and have some basic understanding of using electronics and wiring a breadboard.
To use this display, you can connect it to power (GND and VCC, it can be either 3.3 or 5V) and connect the SDA and SCL pins to the SDA (A4) and SCL (A5) pins of the Arduino. These are hardware i2c pins:
(click images for larger version)
You can mount this display directly onto a breadboard and connect the wires:
Download example sketch
To test this display, you can use this example sketch:
oled_display_i2c_u8g2.ino. Open it in the Arduino IDE. The sketch uses the U8g2 library, which you must install before you use this sketch: In the Arduino IDE, select Tools > Manage Libraries, then search for “U8g2” and install the library.
Next, connect the Arduino to your computer with a USB cable.
Before you upload the example sketch to the Arduino, configure the Arduino IDE to use the correct setting for the type of Arduino you use: under the Tools menu, check the board settings:
The Port can be any active Port (eg. COM1-12, or on Mac OS something like “/dev/tty.usbmodem…” or “/dev/tty.usbserial-…” ). There should be one option you can select here.
Upload the example sketch
Now upload the sketch (press the Upload button ) to transfer the sketch to the Arduino and run it. The display should show some text messages and the value of the variable
To display values of variables with this display, you might need code like this:
display.drawString(0,3,"Speed: "); display.setCursor(7, 3); display.print(speed);
This shows the message “Speed:” on the first part of line 3, then displays the value of variable speed starting at the 7th character position on line 3, to make it appear after the “Speed:” message.