The 2.42 inch OLED display module is a compact and versatile screen suitable for a wide range of electronics projects. With its high contrast and readability, it is commonly used for displaying text, graphics, and animations. The Organic Light Emitting Diode (OLED) technology provides a bright display with a wide viewing angle, making it ideal for handheld devices, user interfaces, and information kiosks.
Pin Number | Pin Name | Description |
---|---|---|
1 | GND | Ground |
2 | VCC | Power supply (3.3V - 5V) |
3 | SCL | Serial Clock Line (SPI/I2C) |
4 | SDA | Serial Data Line (I2C) or MOSI (SPI) |
5 | RES | Reset pin |
6 | DC | Data/Command control pin (SPI) |
7 | CS | Chip Select (SPI) |
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// OLED display TWI address
#define OLED_ADDR 0x3C
// Reset pin not used on 4-pin OLED module
#define RESET_PIN -1
Adafruit_SSD1306 display(128, 64, &Wire, RESET_PIN);
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(;;);
}
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();
delay(2000); // Pause for 2 seconds
}
void loop() {
// Put your main code here, to run repeatedly:
}
Q: Can the display be powered directly from an Arduino UNO? A: Yes, the display can be powered from the 3.3V or 5V output of an Arduino UNO.
Q: How do I adjust the brightness of the display? A: Brightness can be adjusted by changing the contrast settings in the display initialization code.
Q: Is it necessary to use a level shifter with a 5V microcontroller? A: It is recommended to use a level shifter if the display operates at 3.3V and the microcontroller at 5V to prevent damage to the display.