The OLED Display 128x32 is a compact and versatile display module that utilizes organic light-emitting diode (OLED) technology to provide a high-contrast, high-resolution visual output. With a resolution of 128x32 pixels, this display is capable of showing text, graphics, and animations. It is commonly used in consumer electronics, instrumentation panels, and DIY projects, including interfaces with microcontrollers like the Arduino UNO.
Pin Number | Pin Name | Description |
---|---|---|
1 | GND | Ground connection |
2 | VCC | Power supply (3.3V - 5V) |
3 | SCL | Serial Clock Line for I2C |
4 | SDA | Serial Data Line for I2C |
5 | RES | Reset pin (optional, depending on model) |
6 | DC | Data/Command control pin (for SPI) |
7 | CS | Chip Select for SPI (optional, depending on model) |
#include <Wire.h> // Include Wire library for I2C
#include <Adafruit_GFX.h> // Include core graphics library
#include <Adafruit_SSD1306.h> // Include Adafruit_SSD1306 library to control the OLED
// OLED display TWI address (usually 0x3C or 0x3D)
#define OLED_ADDR 0x3C
// Reset pin not used for this display
#define OLED_RESET -1
// Create an instance of the display
Adafruit_SSD1306 display(128, 32, &Wire, OLED_RESET);
void setup() {
// Initialize with the I2C addr 0x3C (for the 128x32)
if(!display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
// Clear the buffer
display.clearDisplay();
// Set text size to 1
display.setTextSize(1);
// Set text color to white
display.setTextColor(WHITE);
// Set cursor position to top-left
display.setCursor(0,0);
// Display text
display.println(F("Hello, OLED!"));
// Show the display buffer on the screen
display.display();
}
void loop() {
// Code to update the display continuously
}
Q: Can the display show images? A: Yes, the display can show bitmap images that fit within its 128x32 pixel resolution.
Q: Is the display readable in sunlight? A: OLED displays are typically not as visible in direct sunlight as backlit LCDs.
Q: How do I prevent screen burn-in? A: Use screen savers or periodically change the content displayed to prevent burn-in.
Q: Can I use this display with a 5V microcontroller? A: Yes, but ensure that the logic levels are compatible or use a level shifter if necessary.