Wyświetlacz OLED 0.91 inch 128 x 32 px


Te same świetne biblioteki pani Ady Owocowej, których używałem z OLED 128×64. Naturalnie w Examples należy wybrać pozycję ssd1306_128x32_i2c


Napisałem prosty program testowy, który rysuje linie z pikseli.

  This is an example for our Monochrome OLEDs based on SSD1306 drivers

  Pick one up today in the adafruit shop!
  ------> http://www.adafruit.com/category/63_98

  This example is for a 128x32 pixel display using I2C to communicate
  3 pins are required to interface (two I2C and one reset).

  Adafruit invests time and resources providing this open
  source code, please support Adafruit and open-source
  hardware by purchasing products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries,
  with contributions from the open source community.
  BSD license, check license.txt for more information
  All text above, and the splash screen below must be
  included in any redistribution.


#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels

// Nano I2C; SDA -> A4; SCL -> A5

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &amp;Wire, OLED_RESET);

boolean flag = 0;

void setup() {

  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32
    Serial.println(F("SSD1306 allocation failed"));
    for (;;); // Don't proceed, loop forever


void loop() {

  // Draw a single pixel in white
  for (int y = 10; y < 26; y = y + 2) {
    for (int x = 10; x < 120; x = x + 1) {
      display.drawPixel(x, y, WHITE);
  if(!flag){flag = true;}else{flag = false;}

Funkcja display.clearDisplay() czasem nie czyści ekranu. Tak się działo przy jednym z moich projektów z ESP8266 NodeMCU. Wtedy należy dodać funkcję display.display().

void screenErase(){  
  Serial.println("Wymazuję ekran");


Dodaj komentarz