#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Define OLED display width and height
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
const uint8_t heartBitmap[] PROGMEM = {
0b00000000, 0b00011000, 0b00111100, 0b01111110, 0b01111110,
0b00111100, 0b00011000, 0b00000000
};
// Initialize the OLED display with I2C address 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Initialize the OLED display
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
while (true); // Don't proceed, loop forever
}
// Clear the display buffer
display.clearDisplay();
// To change color of the letter and background
//display.invertDisplay(true);
// Set text size and color
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
// Display welcome message
display.setCursor(0, 0); // Start at top-left corner
display.println(("Hello, Wokwi!"));
display.println(("ATmega2560 + SSD1306"));
//display.drawBitmap(0, 0, heartBitmap, 8, 8, SSD1306_WHITE); // 8x8 bitmap
//display.startscrollright(0x00, 0x0F); // Update the display with the buffer content
display.display();
}
void loop() {
// Nothing here; display remains static
}