Using a Monochrome 1.3" 128x64 OLED display
What is the OLED monochrome display?
The OLED monochrome display is a small (tiny) and high-readability display. It is useful for displaying data, e.g. weather information or small graphics like what you see on Tamagotchi.
In this tutorial, we will be using Adafruit SSD1306 128 x 64 OLED with I2C communication. It can support SPI communication as well.
Display Configuration
If you have the older non-STEMMA version of the OLED, you'll need to solder the two jumpers on the back of the OLED. Both must be soldered 'closed' for I2C to work!
Wiring
Wiring up the sensor is simple:
- Power (VIN to 5V)
- Ground (GND to GND)
- Data to Arduino SDA pin (A5 on Uno)
- CLK to Arduino SCL pin (A4 on Uno)
Library
To use this code you will need the Adafruit_SSD1306 Library. We have a tutorial on how to install a library here.
Getting started
We will be using the example code ssd1306_128x64_i2c
from the Adafruit_SSD1306
library.
Change the OLED_RESET pin from -1
to 4
.
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
Create your own bitmap
Create your pixel art
Piskel is a free online tool for you to create pixel art. You can specify the canvas size, import images, draw your own graphics etc, and then export it as a PNG.
Convert your image into bitmap code
image2cpp was created by GitHub user javl and provides a handy way to create bitmaps without installing any additional software. Know more here.
Upload your image, select your preferred image settings, and generate code!
You will see the code generated at the bottom and you can paste it in Arduino directly.