Arduino Uno R4 - SSD1309 OLED Display 128x64 | 2.42 Zoll I2C OLED Anleitung

Organic Light-Emitting Diode (OLED) Displays verfügen über selbstleuchtende Pixel, die echte Schwarzwerte, überlegene Kontrastverhältnisse und exzellente Betrachtungswinkel aus allen Richtungen erzeugen — dies bietet erhebliche Vorteile gegenüber herkömmlicher LCD-Technologie. Der SSD1309 Treiber-Chip versorgt die 2.42-Zoll (auch als 2.4-Zoll vermarktet) 128×64 monochromen OLED Module über I2C-Kommunikation.

Arduino Uno R4 SSD1309 OLED 128x64

Diese praktische Anleitung führt Sie durch die Verbindung des SSD1309 OLED 128×64 mit Ihrem Arduino Uno R4 Board über die DIYables_OLED_SSD1309 Bibliothek. Sie werden entdecken, wie Sie:

Benötigte Hardware

1×Arduino Uno R4 WiFi
1×Arduino Uno R4 Minima (Alternativ)
1×USB-Kabel Type-C
1×SSD1309 I2C OLED Display 128x64 (2.42 Zoll)
1×Jumper-Kabel
1×(Empfohlen) Schraubklemmenblock-Shield für Arduino Uno R4
1×(Empfohlen) Breadboard-Shield für Arduino Uno R4
1×(Empfohlen) Gehäuse für Arduino Uno R4
1×(Empfohlen) Stromverteiler für Arduino Uno R4
1×(Empfohlen) Prototyping-Grundplatte & Breadboard-Kit für Arduino Uno

Oder Sie können die folgenden Kits kaufen:

1×DIYables Sensor-Kit (30 Sensoren/Displays)
1×DIYables Sensor-Kit (18 Sensoren/Displays)
Offenlegung: Einige der in diesem Abschnitt bereitgestellten Links sind Amazon-Affiliate-Links. Wir können eine Provision für Käufe erhalten, die über diese Links getätigt werden, ohne zusätzliche Kosten für Sie. Wir schätzen Ihre Unterstützung.

Über das SSD1309 2.42-Zoll OLED Display

Der SSD1309 dient als dedizierter CMOS-Treiber-IC, der für 128×64 Pixel OLED-Matrizen entwickelt wurde. Sein Registersatz behält die Kompatibilität mit dem beliebten SSD1306 bei, wodurch Code-Wiederverwendung mit geringfügigen Anpassungen ermöglicht wird. Bemerkenswerte Hardware-Unterschiede umfassen:

  • Externe Stromversorgung erforderlich — im Gegensatz zur integrierten Ladungspumpe des SSD1306 ist der SSD1309 auf eine externe VCC-Versorgung angewiesen. Jedoch integrieren handelsübliche Breakout-Boards (einschließlich 2.42-Zoll und 2.4-Zoll Varianten) Onboard-Boost-Converter, wodurch dieser Unterschied bei der Verwendung transparent wird.
  • Erweiterte Spannungsbereich — der SSD1309 verarbeitet bis zu 16 V VCC-Eingang, während der SSD1306 bei etwa 4.2 V begrenzt ist.

Das 2.42 Zoll (2.4 Zoll) OLED-Modul verwendet typischerweise den SSD1309-Controller und bietet ein 128×64 Auflösungs-Display, das über das I2C-Protokoll kommuniziert. Die Display-Farbe (weiß, blau, gelb, grün oder dual-farbige Zonen) hängt vom physischen OLED-Substrat ab und kann nicht durch Software-Befehle modifiziert werden.

Diese Anleitung verbindet mit dem Display über den I2C-Bus, erfordert nur zwei Signalleitungen (SDA und SCL) und ermöglicht die Bus-Teilung mit zusätzlichen I2C-Peripheriegeräten.

SSD1309 OLED Pinout (I2C Modul)

Standard 2.42-Zoll SSD1309 I2C OLED Module verfügen über vier Verbindungs-Pins:

  • GND — Verbinden Sie mit Arduino Uno R4 Masse-Referenz.
  • VCC — Stromversorgungseingang. Verbinden Sie mit Arduino Uno R4 5V-Ausgang (oder 3.3V falls das Modul es unterstützt).
  • SCL — I2C-Taktsignalleitung.
  • SDA — I2C-Datensignalleitung.
SSD1309 OLED Pinout

※ Notiz:

  • Die Pin-Anordnung unterscheidet sich zwischen Herstellern. Überprüfen Sie immer die Siebdruck-Beschriftungen auf Ihrem spezifischen Modul, bevor Sie Verbindungen herstellen.
  • Diese Anleitung wurde mit dem 2.42 Zoll SSD1309 OLED Display von DIYables validiert. Andere SSD1309-basierte 2.4/2.42-Zoll Module sollten identisch funktionieren.

Verdrahtungsschema — Arduino Uno R4 & SSD1309 OLED 128×64

  • Schematische Verbindungen zwischen Arduino Uno R4 und dem 2.42 Zoll SSD1309 OLED 128×64
Arduino Uno R4 SSD1309 OLED 128x64 wiring diagram

Dieses Bild wurde mit Fritzing erstellt. Klicken Sie, um das Bild zu vergrößern.

  • Physische Verdrahtungs-Fotografie zwischen Arduino Uno R4 und SSD1309 OLED 128×64
Arduino Uno R4 SSD1309 OLED 128x64 real wiring

Dieses Bild wurde mit Fritzing erstellt. Klicken Sie, um das Bild zu vergrößern.

Siehe Der beste Weg, den Arduino Uno R4 und andere Komponenten mit Strom zu versorgen.

Der Arduino Uno R4 verwendet dieselben I2C-Pin-Positionen wie der klassische Uno. Verbindungsdetails:

OLED ModulArduino Uno R4
Vin5V
GNDGND
SDAA4 (oder SDA Pin)
SCLA5 (oder SCL Pin)

Erste Schritte — SSD1309 OLED mit Arduino Uno R4

Schritt 1: Installation der DIYables_OLED_SSD1309 Bibliothek

  • Starten Sie die Arduino IDE und klicken Sie auf das Libraries Symbol in der linken Seitenleiste.
  • Geben Sie "DIYables_OLED_SSD1309" in das Suchfeld ein und finden Sie die Bibliothek von DIYables.
  • Klicken Sie auf die Install Schaltfläche.
Arduino SSD1309 OLED library
  • Die IDE wird Sie auffordern, die erforderliche Abhängigkeit (Adafruit GFX Library) zu installieren. Klicken Sie auf Install All.
Arduino Adafruit GFX library

Schritt 2: Grundlegende Programmstruktur

Alle SSD1309-Sketches folgen dieser konsistenten Struktur: Header einbinden, ein Display-Objekt instanziieren, es in setup() initialisieren, Inhalt in den Frame-Buffer zeichnen, dann den Buffer mit display() auf den Bildschirm übertragen.

  • Notwendige Header einbinden:
#include <Wire.h> #include <Adafruit_GFX.h> #include <DIYables_OLED_SSD1309.h>
  • Die Bildschirmdimensionen definieren (128×64 für das 2.42-Zoll Modul):
#define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels
  • Das Display-Objekt instanziieren (verwenden Sie -1 wenn kein Reset-Pin verbunden ist):
// Create an SSD1309 display instance on the default I2C bus DIYables_OLED_SSD1309 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
  • Das Display innerhalb von setup() initialisieren:
// Initialize the SSD1309 — use address 0x3C (default for most modules) if (!oled.begin(SSD1309_SWITCHCAPVCC, 0x3C)) { Serial.println(F("SSD1309 allocation failed")); while (true); }
  • Nach der Initialisierung rufen Sie Zeichenfunktionen (clearDisplay(), drawPixel(), print(), etc.) gefolgt von oled.display() auf, um den Bildschirm zu aktualisieren.

※ Notiz:

Alle Code-Beispiele in dieser Anleitung zielen auf das SSD1309 OLED 128×64 (2.42 Zoll) ab und verwenden die DIYables_OLED_SSD1309 Bibliothek mit Arduino Uno R4.

Arduino Uno R4 Code — Hello World auf SSD1309 OLED

Die einfachste Demonstration: Text in verschiedenen Größen anzeigen.

/* * Dieser Arduino UNO R4 Code wurde von newbiely.de entwickelt * Dieser Arduino UNO R4 Code wird der Öffentlichkeit ohne jegliche Einschränkung zur Verfügung gestellt. * Für vollständige Anleitungen und Schaltpläne besuchen Sie bitte: * https://newbiely.de/tutorials/arduino-uno-r4/arduino-uno-r4-ssd1309-oled-display */ /* * DIYables OLED SSD1309 – Hello World * Prints text in two sizes on the 2.42 inch 128x64 I2C OLED. * Compatible with Arduino Uno R4 WiFi and Arduino Uno R4 Minima. */ #include <Wire.h> #include <Adafruit_GFX.h> #include <DIYables_OLED_SSD1309.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 #define SCREEN_ADDRESS 0x3C DIYables_OLED_SSD1309 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); void setup() { Serial.begin(9600); if (!display.begin(SSD1309_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1309 allocation failed")); for (;;); } display.clearDisplay(); display.setTextSize(1); // 6x8 pixels per character display.setTextColor(SSD1309_PIXEL_ON); // turn pixels on display.setCursor(0, 0); display.println(F("Hello, World!")); display.println(); display.setTextSize(2); // 12x16 pixels per character display.println(F("DIYables")); display.setTextSize(1); display.println(); display.println(F("SSD1309 OLED 128x64")); display.display(); // push buffer to screen } void loop() { }

Arduino Uno R4 Code — Text auf SSD1309 OLED anzeigen

Dieses Beispiel zeigt erweiterte Textfunktionen — variable Größen, numerische Formatierung und das F() Makro zur RAM-Einsparung.

/* * Dieser Arduino UNO R4 Code wurde von newbiely.de entwickelt * Dieser Arduino UNO R4 Code wird der Öffentlichkeit ohne jegliche Einschränkung zur Verfügung gestellt. * Für vollständige Anleitungen und Schaltpläne besuchen Sie bitte: * https://newbiely.de/tutorials/arduino-uno-r4/arduino-uno-r4-ssd1309-oled-display */ /* * DIYables OLED SSD1309 – Display Text Demo for Arduino Uno R4 * Demonstrates text display features on 2.42" SSD1309 128x64 I2C OLED. */ #include <Wire.h> #include <Adafruit_GFX.h> #include <DIYables_OLED_SSD1309.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 #define SCREEN_ADDRESS 0x3C DIYables_OLED_SSD1309 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); void setup() { Serial.begin(9600); if (!display.begin(SSD1309_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1309 allocation failed")); for (;;); } delay(2000); // wait for initializing display.clearDisplay(); // clear display display.setTextSize(1); // text size = 1 display.setTextColor(SSD1309_PIXEL_ON); // set text color display.setCursor(0, 10); // set position to display display.println(F("Text size = 1")); // display text display.display(); // update display delay(2000); display.setTextSize(2); // text size = 2 display.setCursor(0, 30); // set position to display display.println(F("Size = 2")); // display text display.display(); // update display delay(2000); display.clearDisplay(); // clear display display.setTextSize(1); display.setCursor(0, 0); display.println(F("Display integer:")); display.println(12345); display.println(); display.println(F("Display float:")); display.println(1.2345); display.println(); display.println(F("Display HEX:")); display.println(0xABCD, HEX); display.display(); // update display } void loop() { }

Nützliche Display-Funktionen Referenz

Schnellreferenz für häufig verwendete SSD1309 OLED-Funktionen über die DIYables-Bibliothek:

  • oled.clearDisplay() — Frame-Buffer löschen (alle Pixel aus).
  • oled.display() — Buffer zum OLED übertragen, um Änderungen sichtbar zu machen.
  • oled.drawPixel(x, y, color) — einzelnes Pixel setzen oder löschen.
  • oled.setTextSize(n) — Schriftart um Faktor *n* skalieren (1 = 6×8, 2 = 12×16, …, bis zu 8).
  • oled.setCursor(x, y) — Text-Cursor auf Pixelkoordinaten *(x, y)* positionieren.
  • oled.setTextColor(SSD1309_PIXEL_ON) — nur Text-Vordergrund (transparenter Hintergrund).
  • oled.setTextColor(SSD1309_PIXEL_OFF, SSD1309_PIXEL_ON) — Text mit expliziter Hintergrundfarbe.
  • oled.println("message") — String drucken und zur nächsten Zeile wechseln.
  • oled.println(number) — Integer im Dezimalformat drucken.
  • oled.println(number, HEX) — Integer im Hexadezimalformat drucken.
  • oled.startscrollright(start, stop) — Hardware-Scrolling nach rechts zwischen Seite *start* und Seite *stop*.
  • oled.startscrollleft(start, stop) — Hardware-Scrolling nach links.
  • oled.startscrolldiagright(start, stop) — Hardware-Scrolling diagonal nach rechts.
  • oled.startscrolldiagleft(start, stop) — Hardware-Scrolling diagonal nach links.
  • oled.stopscroll() — jedes aktive Hardware-Scrolling stoppen.
  • oled.setContrast(value) — Display-Helligkeit anpassen (0–255).
  • oled.dim(true/false) — Display schnell auf Minimum dimmen oder vorherigen Kontrast wiederherstellen.
  • oled.invertDisplay(true/false) — Hardware-Farbinversion (Ein-Pixel ↔ Aus-Pixel).

Wie man Text vertikal und horizontal auf dem SSD1309 OLED zentriert

Siehe How to vertical/horizontal center on OLED

Arduino Uno R4 Code — Formen auf SSD1309 OLED zeichnen

Die DIYables_OLED_SSD1309 Bibliothek erbt von Adafruit_GFX und bietet vollständige Formen-Zeichnungsfunktionen: Pixel, Linien, Rechtecke, gefüllte Rechtecke, Kreise, gefüllte Kreise, Dreiecke, gefüllte Dreiecke und abgerundete Rechtecke. Der folgende Sketch demonstriert alle mit animierten Sequenzen.

/* * Dieser Arduino UNO R4 Code wurde von newbiely.de entwickelt * Dieser Arduino UNO R4 Code wird der Öffentlichkeit ohne jegliche Einschränkung zur Verfügung gestellt. * Für vollständige Anleitungen und Schaltpläne besuchen Sie bitte: * https://newbiely.de/tutorials/arduino-uno-r4/arduino-uno-r4-ssd1309-oled-display */ /* * DIYables OLED SSD1309 – Draw Shapes for Arduino Uno R4 * Cycles through every shape primitive on the 2.42" SSD1309 128x64 OLED. */ #include <Wire.h> #include <Adafruit_GFX.h> #include <DIYables_OLED_SSD1309.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 #define SCREEN_ADDRESS 0x3C DIYables_OLED_SSD1309 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); void setup() { Serial.begin(9600); if (!display.begin(SSD1309_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1309 allocation failed")); for (;;); } display.clearDisplay(); } void loop() { // --- Pixels --- display.clearDisplay(); for (int16_t i = 0; i < display.width(); i += 4) { display.drawPixel(i, i * display.height() / display.width(), SSD1309_PIXEL_ON); } display.display(); delay(1500); // --- Lines --- display.clearDisplay(); for (int16_t i = 0; i < display.width(); i += 8) { display.drawLine(0, 0, i, display.height() - 1, SSD1309_PIXEL_ON); } for (int16_t i = 0; i < display.height(); i += 8) { display.drawLine(0, 0, display.width() - 1, i, SSD1309_PIXEL_ON); } display.display(); delay(1500); // --- Rectangles --- display.clearDisplay(); for (int16_t i = 0; i < display.height() / 2; i += 4) { display.drawRect(i, i, display.width() - 2 * i, display.height() - 2 * i, SSD1309_PIXEL_ON); } display.display(); delay(1500); // --- Filled rectangles (inverse) --- display.clearDisplay(); for (int16_t i = 0; i < display.height() / 2; i += 6) { display.fillRect(i, i, display.width() - 2 * i, display.height() - 2 * i, SSD1309_PIXEL_INVERSE); } display.display(); delay(1500); // --- Circles --- display.clearDisplay(); for (int16_t i = max(display.width(), display.height()) / 2; i > 0; i -= 5) { display.drawCircle(display.width() / 2, display.height() / 2, i, SSD1309_PIXEL_ON); } display.display(); delay(1500); // --- Filled circles (inverse) --- display.clearDisplay(); for (int16_t i = max(display.width(), display.height()) / 2; i > 0; i -= 6) { display.fillCircle(display.width() / 2, display.height() / 2, i, SSD1309_PIXEL_INVERSE); } display.display(); delay(1500); // --- Rounded rectangles --- display.clearDisplay(); for (int16_t i = 0; i < display.height() / 2 - 2; i += 4) { display.drawRoundRect(i, i, display.width() - 2 * i, display.height() - 2 * i, display.height() / 4, SSD1309_PIXEL_ON); } display.display(); delay(1500); // --- Filled rounded rectangles (inverse) --- display.clearDisplay(); for (int16_t i = 0; i < display.height() / 2 - 2; i += 4) { display.fillRoundRect(i, i, display.width() - 2 * i, display.height() - 2 * i, display.height() / 4, SSD1309_PIXEL_INVERSE); } display.display(); delay(1500); // --- Triangles --- display.clearDisplay(); for (int16_t i = 0; i < max(display.width(), display.height()) / 2; i += 5) { display.drawTriangle( display.width() / 2, display.height() / 2 - i, display.width() / 2 - i, display.height() / 2 + i, display.width() / 2 + i, display.height() / 2 + i, SSD1309_PIXEL_ON); } display.display(); delay(1500); // --- Filled triangles (inverse) --- display.clearDisplay(); for (int16_t i = max(display.width(), display.height()) / 2; i > 0; i -= 6) { display.fillTriangle( display.width() / 2, display.height() / 2 - i, display.width() / 2 - i, display.height() / 2 + i, display.width() / 2 + i, display.height() / 2 + i, SSD1309_PIXEL_INVERSE); } display.display(); delay(1500); }

Arduino Uno R4 Code — Hardware-Scrolling auf SSD1309 OLED

Der SSD1309 umfasst eine Hardware-Scrolling-Engine, die Display-Inhalte ohne CPU-Intervention bewegt. Die DIYables-Bibliothek bietet vier Scroll-Modi: rechts, links, diagonal-rechts und diagonal-links. Jeder akzeptiert einen Start-Seiten- und Stop-Seiten-Parameter (Seiten sind 8-Pixel-hohe horizontale Bänder, nummeriert 0–7 auf einem 64-Pixel-hohen Display).

※ Notiz:

Rufen Sie immer display() auf, um Ihren Inhalt zum OLED zu übertragen bevor Sie ein Scrolling initiieren. Vermeiden Sie das Rendern neuer Inhalte während das Scrolling aktiv ist — rufen Sie zuerst stopscroll() auf.

/* * Dieser Arduino UNO R4 Code wurde von newbiely.de entwickelt * Dieser Arduino UNO R4 Code wird der Öffentlichkeit ohne jegliche Einschränkung zur Verfügung gestellt. * Für vollständige Anleitungen und Schaltpläne besuchen Sie bitte: * https://newbiely.de/tutorials/arduino-uno-r4/arduino-uno-r4-ssd1309-oled-display */ /* * DIYables OLED SSD1309 – Scroll Text * Demonstrates all four hardware scroll directions on the 2.42" OLED. * Compatible with Arduino Uno R4 WiFi and Arduino Uno R4 Minima. */ #include <Wire.h> #include <Adafruit_GFX.h> #include <DIYables_OLED_SSD1309.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 #define SCREEN_ADDRESS 0x3C DIYables_OLED_SSD1309 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); void setup() { Serial.begin(9600); if (!display.begin(SSD1309_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1309 allocation failed")); for (;;); } display.clearDisplay(); display.setTextSize(2); display.setTextColor(SSD1309_PIXEL_ON); display.setCursor(10, 24); display.println(F("DIYables")); display.display(); delay(2000); } void loop() { // Scroll right across all pages display.startscrollright(0x00, 0x07); delay(3000); display.stopscroll(); delay(500); // Scroll left display.startscrollleft(0x00, 0x07); delay(3000); display.stopscroll(); delay(500); // Diagonal scroll right display.startscrolldiagright(0x00, 0x07); delay(3000); display.stopscroll(); delay(500); // Diagonal scroll left display.startscrolldiagleft(0x00, 0x07); delay(3000); display.stopscroll(); delay(500); }

Arduino Uno R4 Code — Bitmap-Bild auf SSD1309 OLED anzeigen

Um eine Bitmap auf dem SSD1309 OLED anzuzeigen, müssen Sie zuerst Ihr Bild in ein C-Byte-Array konvertieren. Verwenden Sie das kostenlose image2cpp Online-Tool für diese Konvertierung:

  1. Laden Sie Ihre Bilddatei hoch (PNG, JPG, BMP, etc.).
  2. Konfigurieren Sie die Canvas-Größe auf 128×64 (oder kleiner).
  3. Wählen Sie Arduino code als Ausgabeformat.
  4. Kopieren Sie das generierte Array in Ihren Sketch.
image to bitmap array

Das folgende Beispiel wechselt zwischen einem 16×16 Herz-Icon und einem vollbreiten DIYables-Logo:

/* * Dieser Arduino UNO R4 Code wurde von newbiely.de entwickelt * Dieser Arduino UNO R4 Code wird der Öffentlichkeit ohne jegliche Einschränkung zur Verfügung gestellt. * Für vollständige Anleitungen und Schaltpläne besuchen Sie bitte: * https://newbiely.de/tutorials/arduino-uno-r4/arduino-uno-r4-ssd1309-oled-display */ /* * DIYables OLED SSD1309 – Display Image Demo for Arduino Uno R4 * Displays bitmap images on the 2.42" SSD1309 128x64 I2C OLED. */ #include <Wire.h> #include <Adafruit_GFX.h> #include <DIYables_OLED_SSD1309.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 #define SCREEN_ADDRESS 0x3C DIYables_OLED_SSD1309 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); // 16x16 heart bitmap const unsigned char heart16x16[] PROGMEM = { 0x00, 0x00, 0x03, 0xc0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f, 0xfc, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0x3f, 0xfc, 0x1f, 0xf8, 0x0f, 0xf0, 0x03, 0xc0, 0x00, 0x00 }; // 128x64 DIYables logo bitmap const unsigned char diyablesLogo[] PROGMEM = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x03, 0xff, 0xfc, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xf8, 0x00, 0x0f, 0xff, 0xff, 0x00, 0x00, 0x3f, 0xf0, 0x00, 0x03, 0xff, 0xff, 0xc0, 0x00, 0x7f, 0xf0, 0x00, 0x1f, 0xff, 0xff, 0xc0, 0x00, 0x1f, 0xe0, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, 0x7f, 0xf0, 0x00, 0x7f, 0xff, 0xff, 0xe0, 0x00, 0x0f, 0xc0, 0x00, 0x1f, 0xff, 0xff, 0xf8, 0x00, 0x3f, 0xe0, 0x00, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x07, 0x80, 0x00, 0x7f, 0xff, 0xff, 0xfc, 0x00, 0x1f, 0xe0, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x03, 0x80, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x1f, 0xc0, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x03, 0x00, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x1f, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x07, 0xff, 0xf0, 0x7f, 0xff, 0x00, 0x0f, 0xc0, 0x07, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x0f, 0xff, 0xf0, 0x7f, 0xff, 0x80, 0x0f, 0x80, 0x07, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x1f, 0xff, 0xf0, 0x7f, 0xff, 0x80, 0x07, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xf0, 0x7f, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x7f, 0xff, 0xf0, 0x7f, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xfe, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x03, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xfe, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x01, 0xff, 0xfc, 0x00, 0x01, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xfe, 0x00, 0x00, 0xff, 0xff, 0x00, 0x03, 0xff, 0xfc, 0x00, 0x01, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xfe, 0x00, 0x00, 0xff, 0xff, 0x00, 0x03, 0xff, 0xfc, 0x00, 0x01, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xfe, 0x00, 0x00, 0xff, 0xff, 0x00, 0x03, 0xff, 0xfc, 0x00, 0x01, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x01, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x7f, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x7f, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x7f, 0xff, 0xf0, 0x7f, 0xff, 0xc0, 0x07, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x3f, 0xff, 0xf0, 0x7f, 0xff, 0x80, 0x07, 0x80, 0x07, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x1f, 0xff, 0xf0, 0x7f, 0xff, 0x80, 0x07, 0xc0, 0x07, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0x80, 0x0f, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xe0, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x03, 0x00, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x1f, 0xe0, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x07, 0x80, 0x00, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x1f, 0xe0, 0x00, 0x7f, 0xff, 0xff, 0xf0, 0x00, 0x0f, 0xc0, 0x00, 0x3f, 0xff, 0xff, 0xf8, 0x00, 0x3f, 0xf0, 0x00, 0x3f, 0xff, 0xff, 0xe0, 0x00, 0x1f, 0xe0, 0x00, 0x1f, 0xff, 0xff, 0xf0, 0x00, 0x3f, 0xf8, 0x00, 0x1f, 0xff, 0xff, 0x80, 0x00, 0x3f, 0xe0, 0x00, 0x07, 0xff, 0xff, 0xe0, 0x00, 0x7f, 0xf8, 0x00, 0x0f, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x03, 0xff, 0xff, 0xc0, 0x00, 0x7f, 0xfc, 0x00, 0x03, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xfc, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xfe, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x01, 0xff, 0xfe, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x01, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; void setup() { Serial.begin(9600); if (!display.begin(SSD1309_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1309 allocation failed")); for (;;); } delay(2000); display.setCursor(0, 0); } void loop() { // Display 16x16 heart icon display.clearDisplay(); display.drawBitmap((SCREEN_WIDTH - 16) / 2, (SCREEN_HEIGHT - 16) / 2, heart16x16, 16, 16, SSD1309_PIXEL_ON); display.display(); delay(2000); // Display full-screen DIYables logo display.clearDisplay(); display.drawBitmap(0, 0, diyablesLogo, 128, 64, SSD1309_PIXEL_ON); display.display(); delay(2000); // Invert display display.invertDisplay(true); delay(2000); display.invertDisplay(false); delay(500); }

※ Notiz:

  • Bitmap-Dimensionen dürfen die Bildschirmauflösung nicht überschreiten (128×64 für das 2.42 Zoll Modul).

Arduino Uno R4 Code — Kontrast und Dimmen auf SSD1309 OLED

Der SSD1309 bietet 256 Kontraststufen (0–255). Die DIYables-Bibliothek stellt setContrast() für präzise Kontrolle und dim() für schnelles Umschalten zwischen minimaler Helligkeit und dem zuvor eingestellten Level bereit.

/* * Dieser Arduino UNO R4 Code wurde von newbiely.de entwickelt * Dieser Arduino UNO R4 Code wird der Öffentlichkeit ohne jegliche Einschränkung zur Verfügung gestellt. * Für vollständige Anleitungen und Schaltpläne besuchen Sie bitte: * https://newbiely.de/tutorials/arduino-uno-r4/arduino-uno-r4-ssd1309-oled-display */ /* * DIYables OLED SSD1309 – Contrast & Dim * Sweeps contrast from 0→255→0 then toggles dim mode on the 2.42" OLED. * Compatible with Arduino Uno R4 WiFi and Arduino Uno R4 Minima. */ #include <Wire.h> #include <Adafruit_GFX.h> #include <DIYables_OLED_SSD1309.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 #define SCREEN_ADDRESS 0x3C DIYables_OLED_SSD1309 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); void setup() { Serial.begin(9600); if (!display.begin(SSD1309_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1309 allocation failed")); for (;;); } // Draw a test pattern so the contrast changes are visible display.clearDisplay(); display.fillRect(0, 0, 64, 32, SSD1309_PIXEL_ON); display.fillRect(64, 32, 64, 32, SSD1309_PIXEL_ON); display.setTextSize(1); display.setTextColor(SSD1309_PIXEL_INVERSE); display.setCursor(16, 28); display.println(F("Contrast Demo")); display.display(); delay(2000); } void loop() { // Ramp up for (int c = 0; c <= 255; c += 5) { display.setContrast((uint8_t)c); delay(30); } delay(1000); // Ramp down for (int c = 255; c >= 0; c -= 5) { display.setContrast((uint8_t)c); delay(30); } delay(1000); // Quick dim toggle display.dim(true); // minimum brightness delay(2000); display.dim(false); // restore delay(2000); }

Arduino Uno R4 Code — Benutzerdefinierte externe Schriftarten auf SSD1309 OLED

Die Adafruit GFX Bibliothek umfasst Dutzende skalierbarer FreeFont Schriftarten (Serif, Sans, Mono — jeweils in Regular, Bold, Italic und mehreren Größen). Sie können jede davon auf dem SSD1309 Display verwenden, indem Sie den relevanten Header einbinden und setFont() aufrufen.

※ Notiz:

  • Wenn eine externe Schriftart aktiv ist, bezieht sich die Cursor-Y-Koordinate auf die Text-Grundlinie, nicht auf die obere linke Ecke. Dies unterscheidet sich vom Verhalten der eingebauten 5×7 Schriftart.
  • Externe Schriftarten werden im Flash (PROGMEM) gespeichert. Bei speicherbeschränkten Boards wie dem klassischen Uno (32 KB Flash) verwenden Sie sie sparsam. Der Arduino Uno R4 hat mehr Speicher und ermöglicht mehr Flexibilität.
/* * Dieser Arduino UNO R4 Code wurde von newbiely.de entwickelt * Dieser Arduino UNO R4 Code wird der Öffentlichkeit ohne jegliche Einschränkung zur Verfügung gestellt. * Für vollständige Anleitungen und Schaltpläne besuchen Sie bitte: * https://newbiely.de/tutorials/arduino-uno-r4/arduino-uno-r4-ssd1309-oled-display */ /* * DIYables OLED SSD1309 – External Fonts * Cycles through three FreeFont typefaces on the 2.42" SSD1309 OLED. * Compatible with Arduino Uno R4 WiFi and Arduino Uno R4 Minima. */ #include <Wire.h> #include <Adafruit_GFX.h> #include <DIYables_OLED_SSD1309.h> #include <Fonts/FreeSerif9pt7b.h> #include <Fonts/FreeSansBold12pt7b.h> #include <Fonts/FreeMono9pt7b.h> #define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64 #define OLED_RESET -1 #define SCREEN_ADDRESS 0x3C DIYables_OLED_SSD1309 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); void setup() { Serial.begin(9600); if (!display.begin(SSD1309_SWITCHCAPVCC, SCREEN_ADDRESS)) { Serial.println(F("SSD1309 allocation failed")); for (;;); } display.clearDisplay(); display.display(); } void loop() { // ── Built-in 5×7 font ── display.clearDisplay(); display.setFont(NULL); display.setTextSize(1); display.setTextColor(SSD1309_PIXEL_ON); display.setCursor(0, 0); display.println(F("Built-in 5x7 font")); display.println(); display.setTextSize(2); display.println(F("DIYables")); display.display(); delay(3000); // ── FreeSerif 9pt ── display.clearDisplay(); display.setFont(&FreeSerif9pt7b); display.setTextSize(1); display.setTextColor(SSD1309_PIXEL_ON); display.setCursor(0, 14); // Y = baseline display.println(F("FreeSerif 9pt")); display.setCursor(0, 38); display.println(F("DIYables OLED")); display.setCursor(0, 58); display.println(F("Hello World!")); display.display(); delay(3000); // ── FreeSansBold 12pt ── display.clearDisplay(); display.setFont(&FreeSansBold12pt7b); display.setTextSize(1); display.setTextColor(SSD1309_PIXEL_ON); display.setCursor(0, 20); display.println(F("SansBold")); display.setCursor(0, 52); display.println(F("DIYables")); display.display(); delay(3000); // ── FreeMono 9pt ── display.clearDisplay(); display.setFont(&FreeMono9pt7b); display.setTextSize(1); display.setTextColor(SSD1309_PIXEL_ON); display.setCursor(0, 14); display.println(F("FreeMono 9pt")); display.setCursor(0, 34); display.println(F("0123456789")); display.setCursor(0, 54); display.println(F("!@#$%^&*()")); display.display(); delay(3000); }

SSD1309 OLED Fehlerbehebung mit Arduino Uno R4

Wenn das 2.42 Zoll SSD1309 OLED nach dem Hochladen Ihres Sketches leer bleibt, arbeiten Sie diese Diagnoseschritte durch:

  • Verbindungen überprüfen — bestätigen Sie, dass SDA, SCL, VCC und GND mit den korrekten Arduino Uno R4 Pins verdrahtet sind.
  • Treiber-Chip bestätigen — diese Bibliothek ist für den SSD1309 entwickelt. Wenn Ihr Modul einen anderen Controller verwendet (z.B. SH1106), wird es nicht korrekt antworten.
  • I2C-Adresse prüfen — die meisten SSD1309 Module verwenden standardmäßig 0x3C, aber einige verwenden 0x3D. Führen Sie den I2C-Scanner-Sketch unten aus, um die tatsächliche Adresse zu erkennen:
// I2C address scanner — prints every detected device to the Serial Monitor #include <Wire.h> void setup() { Wire.begin(); Serial.begin(9600); Serial.println("I2C Scanner"); } void loop() { byte error, address; int nDevices = 0; Serial.println("Scanning..."); for (address = 1; address < 127; address++) { Wire.beginTransmission(address); error = Wire.endTransmission(); if (error == 0) { Serial.print("I2C device found at address 0x"); if (address < 16) Serial.print("0"); Serial.print(address, HEX); Serial.println(" !"); nDevices++; } else if (error == 4) { Serial.print("Unknown error at address 0x"); if (address < 16) Serial.print("0"); Serial.println(address, HEX); } } if (nDevices == 0) Serial.println("No I2C devices found"); else Serial.println("done"); delay(5000); }

Erwartete Serial Monitor Ausgabe, wenn der SSD1309 erkannt wird:

COM6
Send
Scanning... I2C device found at address 0x3C ! done
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  
  • Sicherstellen, dass display() aufgerufen wird — der SSD1309 verwendet einen Frame-Buffer. Zeichenfunktionen modifizieren nur den Buffer im RAM; nichts erscheint auf dem Bildschirm, bis Sie oled.display() aufrufen.
  • Stromversorgung prüfen — das 2.42 Zoll Modul zieht mehr Strom als kleinere OLEDs. Stellen Sie sicher, dass Ihre Stromquelle ausreichend Strom liefern kann (typischerweise 20–40 mA bei voller Helligkeit).

※ UNSERE NACHRICHTEN

  • Sie können gerne den Link zu diesem Tutorial teilen. Bitte verwenden Sie jedoch unsere Inhalte nicht auf anderen Websites. Wir haben viel Mühe und Zeit in die Erstellung der Inhalte investiert, bitte respektieren Sie unsere Arbeit!