To moduł wyświetlacza OLED 2,4 cala przeznaczony do współpracy z mikrokontrolerami przez interfejs I2C (SDA/SCL). Jest zaprojektowany do pracy z zasilaniem 3,3V (VDD) i wykorzystuje GND jako masę; zwykle dostępne są zdublowane piny SDA/SCL oraz zasilania/masy, aby ułatwić okablowanie. Wyświetlacz jest często używany do wyświetlania tekstu i prostych grafik w projektach edukacyjnych Arduino/ESP32.
| Pin | Sygnał | Opis |
|---|---|---|
SDA |
SDA | I2C serial data line for the OLED display; connect to MCU SDA. |
SCL |
SCL | I2C serial clock line for the OLED display; connect to MCU SCL. |
GND |
ground | Ground reference for the OLED module and I2C interface. |
VDD |
power | 3.3V power input for the OLED display module. |
GND.1 |
ground | Ground reference for the OLED module and I2C interface. |
VDD.1 |
power | 3.3V power input for the OLED display module. |
SCL.1 |
SCL | I2C serial clock line for the OLED display; connect to MCU SCL. |
SDA.1 |
SDA | I2C serial data line for the OLED display; connect to MCU SDA. |
| Z | Do | Przewód |
|---|---|---|
board:5V |
x1:VDD |
red |
board:GND |
x1:GND |
black |
board:SDA |
x1:SDA |
green |
board:SCL |
x1:SCL |
blue |
Ten przykład został napisany i sprawdzony kompilacją dla arduino-uno. Codey Online dostosuje go do każdej innej obsługiwanej płytki.
#include <Wire.h>
#include <U8g2lib.h>
// 2.4 inch OLED Display I2C 3.3V
// Arduino Uno uses SDA on A4 and SCL on A5.
// This example uses the common U8g2 library with a widely supported SH1106/128x64-style setup.
U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);
void setup() {
Wire.begin();
u8g2.begin();
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_6x12_tr);
u8g2.drawStr(0, 14, "Hello, OLED!");
u8g2.drawStr(0, 30, "Arduino Uno I2C demo");
u8g2.drawStr(0, 46, "2.4 inch OLED 3.3V");
u8g2.sendBuffer();
Serial.begin(9600);
Serial.println("OLED initialized and text drawn.");
}
void loop() {
static unsigned long counter = 0;
static unsigned long lastUpdate = 0;
if (millis() - lastUpdate >= 1000) {
lastUpdate = millis();
counter++;
char line[24];
snprintf(line, sizeof(line), "Seconds: %lu", counter);
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_6x12_tr);
u8g2.drawStr(0, 14, "Hello, OLED!");
u8g2.drawStr(0, 30, "Arduino Uno I2C demo");
u8g2.drawStr(0, 46, line);
u8g2.sendBuffer();
Serial.println(line);
}
}
Opisz, co chcesz zbudować. Codey Online napisze kod, narysuje schemat połączeń, skompiluje projekt i wgra go na płytkę bezpośrednio z przeglądarki.
Zacznij za darmo