In this project, users will see how to set up the Pmod OLEDrgbPmod OLEDrgb 96 x 64 RGB OLED Display with 16-bit color resolution with the Arduino Uno in order to display different sizes and color messages.
The Pmod OLEDrgbPmod OLEDrgb features a 96x64-pixel RGB OLED display that is capable of 16-bit color resolution. As a graphical display, users may show off graphs, full-color pictures, text, and anything else they want to see by communicating with it through a standard SPI interface. The Pmod OLEDrgb utilizes a Solomon Systech SSD1331 display controller to receive information from the host board and display the desired information on the OLED screen. The SSD1331 is a single-chip CMOS OLED/PLED driver with 288 segments and 64 commons output, supporting up to 96RGB x 64 dot matrix display. It has embedded Graphic Display Data RAM (GDDRAM). It supports with 8, 9, 16 bits 8080 / 6800 parallel interface as well as serial peripheral interface.
The Pmod OLEDrgb communicates with the host board via the SPI protocol. By driving and keeping the Chip Select (CS) line at a logic level low, users may send both commands and data streams to the display controller based on the state of the Data/Command (D/C) pin. The display controller operates in SPI Mode 3 (clock idles on logic high, data is captured on the clock rising edge, and data is transferred on the clock falling edge) and with a minimum clock cycle time of 150 ns. The embedded display only supports SPI write, so users will not be able to receive any information back from the display over SPI. As a graphical display interface, users may light up any individual pixel on the OLED, display predefined characters, or even load bitmaps onto the screen. Each pixel can be set to one of the 65,535 colors that are available in a 5-6-5 bit RGB format. The OLED display has a specific power-up and power-down sequence to ensure the longevity of the device.
Quick Configuration Commands
You can run a sequence of commands to configure the display when the Pmod is powered on and off. For example,
Enable the driver IC to accept commands by sending the unlock command over SPI (0xFD, 0x12).
SpiWriteMultiple(2, 0xFD, 0x12); //Write two bytes-- the (un)lock commands register and the byte value to set the register to unlock command mode
Send the display off command.
SpiWrite(0xAE); //Turn off the display with a one byte command
Set the Display start Line to the top line (0xA1, 0x00).
SpiWriteMultiple(2, 0xA1, 0x00); //Write two bytes-- the set display start line command and the single byte value for the top line
Make it a normal display with no color inversion or forcing the pixels on/off (0xA4).
SpiWrite(0xA4); //A single byte value for a normal display
Find all the data acquisition commands on the Pmod OLEDrgb Reference Page.
Connecting the Pmod OLEDrgb to Arduino Uno
Follow the below instructions to connect Pmod OLEDrgb to Arduino Uno.
| Pmod Pin | Arduino Uno Pins |
|---|---|
| Vcc | 3V3 |
| GND | GND |
| SCK | 13 (SCK) |
| MOSI | 11 (MOSI) |
| CS | 10 |
| D/C | 9 |
| RES | 8 |
| VCCEN | 3V3 |
| PmodEN | 3V3 |
Software applications
PmodOLEDrgb communication with Arduino Uno through SPI (SPI mode 3). The Adafruit_SSD1331.h library is used to control the display. This library includes the Adafruit-GFX library (https://github.com/adafruit/Adafruit-GFX-Library) which provides functions for displaying text and geometrics in different sizes and colors.
First of all, all pins and color hex codes are defined. Then, an object is created. Then the display is initialized.
The display background is set and cleared after each run. A range of member functions are used to
- Set the color, cursor position and text size
- Display one character at a time in the string literal "PMODLED"
Project code
/************************************************************************
Test of the Pmod OLEDrgb
*************************************************************************
Description: Pmod_OLEDrgb
A test message will be displayed on the OLEDrgb module
with different size and colors
Material
1. Arduino Uno
2. Pmod OLEDrgb
3. breadboard
https://github.com/adafruit/Adafruit-SSD1331-OLED-Driver-Library-for-Arduino
https://github.com/adafruit/Adafruit-GFX-Library
************************************************************************/
//pin definitions
#define SCK 13 //serial clock
#define MOSI 11 //master-out slave-in
#define CS 10 //chip select
#define DC 9 //data/command control
#define RES 8 //power reset
#include <Adafruit_SSD1331.h> //include display library
//define colors
#define black 0x0000
#define blue 0x001F
#define red 0xF800
#define green 0x07E0
#define cyan 0x07FF
#define magenta 0xF81F
#define yellow 0xFFE0
#define white 0xFFFF
Adafruit_SSD1331 display = Adafruit_SSD1331(CS, DC, MOSI, SCK, RES); //create the object
void setup() {
display.begin(); //initialize the display
}
void loop() {
display.fillScreen(black); //set background and clear everything
//display text
display.setTextColor(white); //set text color
display.setCursor(25, 0); //set cursor position (x, y)
display.setTextSize(1); //set the size of text
display.print("Testing:"); // display text
//display one letter at a time
char test[] = {"PMODOLED"}; //store characters
display.setTextColor(cyan); //set text color
display.setCursor(25, 15); //set cursor position (x, y)
display.setTextSize(2); //set the size of text
for (int i = 0; i < 4; i++) {
display.print(test[i]);
delay(200);
}
//continue in a new line
display.setTextColor(yellow); //set text color
display.setCursor(5, 40); //set cursor position (x, y)
for (int i = 4; i < 8; i++) {
display.print(test[i]);
delay(200);
}
//letters with different colors
display.setTextColor(red); //set text color
display.print("r");
delay(200);
display.setTextColor(green); //set text color
display.print("g");
delay(200);
display.setTextColor(blue); //set text color
display.print("b");
delay(200);
delay(5000);
}



Top Comments