#include <SPI.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup ()
{
if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C))
{
Serial.println(F("SSD1306 allocation failed"));
while (true);
}
}
void loop ()
{
for(int i = 14; i<=100; i++)
{
oled.clearDisplay();
oled.drawRect(10, 10, 118, 54, WHITE);
oled.fillRect(14,12, 100, 52, WHITE);
oled.display();
delay(10);
}
for(int i = 100; i>=14; i++)
{
oled.clearDisplay();
oled.drawRect(10, 10, 118, 54, WHITE);
oled.fillRect(14,12, 100, 52, WHITE);
oled.display();
delay(10);
}
}Loading
esp32-c3-devkitm-1
esp32-c3-devkitm-1
Loading
ssd1306
ssd1306