top of page

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

 

// OLED setup

#define SCREEN_WIDTH 128

#define SCREEN_HEIGHT 64

#define OLED_RESET    -1

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

 

void setup() {

  Serial.begin(9600);

 

  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // 0x3C is the usual address

    Serial.println(F("SSD1306 allocation failed"));

    for (;;);

  }

 

  display.clearDisplay();

  display.setTextSize(1);

  display.setTextColor(SSD1306_WHITE);

 

  // Display initial text

  display.setCursor(0, 0);

  display.println("OLED Test Ready!");

  display.display();

  delay(2000);

}

 

void loop() {

  static int barWidth = 0;

  static bool increasing = true;

 

  display.clearDisplay();

 

  // Text

  display.setCursor(0, 0);

  display.println("OLED Test");

 

  // Draw rectangle outline

  display.drawRect(4, 20, 120, 12, SSD1306_WHITE);

 

  // Fill rectangle as bar

  display.fillRect(4, 20, barWidth, 12, SSD1306_WHITE);

 

  display.display();

 

  // Update bar for animation

  if (increasing) {

    barWidth += 2;

    if (barWidth >= 120) increasing = false;

  } else {

    barWidth -= 2;

    if (barWidth <= 0) increasing = true;

  }

 

  delay(50);

}

 

0.96 Inch OLED White Color 128X64

SKU: DIS547
R₣7,000Price
Quantity
    No Reviews YetShare your thoughts. Be the first to leave a review.
    bottom of page