The 0.96" OLED display module is a compact and versatile screen suitable for adding a visual interface to your electronics projects. With its Organic Light-Emitting Diode (OLED) technology, it provides high contrast, vibrant colors, and wide viewing angles. This display is commonly used in wearable devices, small instruments, and any application where a small yet clear display is required.
Pin Number | Pin Name | Description |
---|---|---|
1 | GND | Ground |
2 | VCC | Power supply (3.3V - 5V) |
3 | SCL | Serial Clock Line (I2C) or SPI Clock (SPI) |
4 | SDA | Serial Data Line (I2C) or SPI Data In (SPI) |
5 | RES | Reset (optional for some models) |
6 | DC | Data/Command (SPI only) |
7 | CS | Chip Select (SPI only) |
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// OLED display TWI address (usually 0x3C or 0x3D)
#define OLED_ADDR 0x3C
// Reset pin not used on 4-pin OLED module but required for library
#define OLED_RESET -1
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);
void setup() {
// Initialize with the I2C addr 0x3C (for the 128x64)
if(!display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
display.display();
delay(2000); // Pause for 2 seconds
// Clear the buffer
display.clearDisplay();
// Draw a single pixel in white
display.drawPixel(10, 10, WHITE);
// Show the display buffer on the screen
display.display();
}
void loop() {
// Code to update the display continuously
}
Q: Can I use this display with a 5V microcontroller? A: Yes, most 0.96" OLED displays are 5V tolerant, but always check the specifications of your particular module.
Q: How do I know if my OLED is using I2C or SPI? A: Check the pinout and the documentation provided by the manufacturer. I2C modules typically have fewer pins.
Q: Can I display images on the OLED? A: Yes, you can display bitmap images, but they need to be converted to a monochrome format suitable for the display's resolution.
Q: Is it possible to use multiple OLED displays with an Arduino? A: Yes, with I2C you can use multiple displays with different addresses. With SPI, you can use multiple displays by selecting different CS pins for each one.