#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// OLED display TWI address
#define OLED_ADDR 0x3C
// OLED display width and height
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
// If your display has a reset pin, define it here
#define OLED_RESET_PIN -1 // replace -1 with the actual pin number if needed
// Define the display
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET_PIN);
void setup() {
// Initialize the display
if(!display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
display.clearDisplay();
// Draw a smiley face
drawSmileyFace();
}
void loop() {
// You can add more code here to change the display or add animations
}
void drawSmileyFace() {
display.clearDisplay(); // Clear the display buffer
// Draw the face
display.fillCircle(64, 32, 31, WHITE);
// Draw the eyes
display.fillCircle(50, 24, 5, WHITE);
display.fillCircle(78, 24, 5, WHITE);
// Draw the mouth
display.drawCircle(64, 32, 20, BLACK);
display.drawCircle(64, 32, 21, BLACK);
display.fillCircle(64, 46, 2, BLACK);
display.display(); // Update the display with the drawn content
}