#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_I2C_ADDR 0x3C // or 0x3C
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RST_PIN -1 // Reset pin (-1 if not available)
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RST_PIN);
int xAcc = 1;
int yAcc = -1;
int realX = 2;
int realY = 6;
// OLED Animation: upload
// Code auto-generated by https://wokwi.com/animator, graphics by icons8.com
#define FRAME_DELAY (42)
#define FRAME_WIDTH (63)
#define FRAME_HEIGHT (32)
const unsigned char frame [] PROGMEM = {
0x3f, 0xfc, 0x1f, 0xf8, 0x3f, 0xfc, 0x3f, 0xfc, 0x01, 0xfc, 0x78, 0x1e, 0x70, 0xfe, 0x77, 0x0e,
0x70, 0xee, 0xe7, 0x0e, 0x71, 0xef, 0xce, 0x1c, 0xf7, 0xc7, 0x8f, 0x7c, 0xff, 0x07, 0x0f, 0xf0,
0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x03, 0xff, 0xff, 0x80, 0x7f, 0xf8, 0x3f, 0xfc,
0xff, 0xf0, 0x1f, 0xfe, 0x3f, 0xff, 0xff, 0xf8, 0x01, 0xff, 0xff, 0x00
};
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, SCREEN_I2C_ADDR);
}
void loop() {
display.clearDisplay();
display.drawBitmap(realX, realY, frame, 31, 15, 1);
display.display();
if (realX == 0) {
xAcc = 1;
} else if (realX + 31 == 128) {
xAcc = -1;
}
if (realY == 0) {
yAcc = 1;
} else if (realY + 15 == 64) {
yAcc = -1;
}
realX += xAcc;
realY += yAcc;
delay(36);
}
Loading
ssd1306
ssd1306