The Adafruit Grayscale 1.5in 128x128 OLED Graphic Display is a compact and versatile monochrome display module. With a resolution of 128x128 pixels, it offers high contrast and excellent visibility under various lighting conditions. This display is perfect for projects that require a small yet clear interface to show text, graphics, or custom user interfaces.
Pin Number | Name | Description |
---|---|---|
1 | GND | Ground connection |
2 | VCC | Power supply (3.3V - 5V) |
3 | SCL | Serial Clock Line for I2C/SPI |
4 | SDA | Serial Data Line for I2C or MOSI for SPI |
5 | RES | Reset pin |
6 | DC | Data/Command control pin for SPI |
7 | CS | Chip Select for SPI |
Power Connections: Connect the VCC pin to a 3.3V or 5V power supply and the GND pin to the ground.
Data Connections: For I2C communication, connect the SCL and SDA pins to the corresponding SCL and SDA pins on your microcontroller. For SPI communication, connect SCL to SCK, SDA to MOSI, DC to a digital pin for data/command selection, CS to a digital pin for chip selection, and RES to a digital pin for resetting the display.
Initialization: Before sending data to the display, initialize it using the appropriate library and set the communication protocol (I2C/SPI).
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1327.h> // Include the SSD1327 grayscale OLED driver library
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 128 // OLED display width and height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3D // I2C address for the display
Adafruit_SSD1327 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
void setup() {
// Initialize with the I2C addr 0x3D (for the 128x128)
if(!display.begin(SSD1327_I2C_ADDRESS, OLED_RESET)) {
Serial.println(F("SSD1327 allocation failed"));
for(;;);
}
display.display(); // Show initial display buffer contents on the screen
delay(2000); // Pause for 2 seconds
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1327_WHITE); // Draw white text
display.setCursor(0, 0); // Start at top-left corner
display.print(F("Hello, world!"));
display.display();
}
void loop() {
// There's no need to update the display continuously in this example
// The text "Hello, world!" will remain on the screen
}
Q: Can the display be used with both 3.3V and 5V logic? A: Yes, but level shifting is recommended when using 5V logic.
Q: Is the display sunlight-readable? A: The OLED display is visible in sunlight, but prolonged exposure to direct sunlight should be avoided.
Q: How can I display images on the OLED? A: Convert your images to a bitmap array and use the display library's drawing functions to render the image on the screen.