#include <Wire.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4 // Reset pin for OLED (can be any digital pin)
Adafruit_SSD1306 display(OLED_RESET);
void setup() {
// Initialize the OLED display
display.begin(SSD1306_SWITCHCAPVCC, 0x3D); // Address 0x3C for 128x64 OLED
// Clear the display buffer
display.clearDisplay();
// Add your setup code here
}
void loop() {
// Clear the display buffer
display.clearDisplay();
// Add your loop code here
// Display text
display.setTextSize(1); // Set text size. Increase the value for larger text.
display.setTextColor(WHITE); // Set text color. Options: WHITE, BLACK, INVERSE
display.setCursor(0, 0); // Set the cursor position (x, y)
display.println("Hello, World!"); // Print text to display buffer
// Display graphics
display.drawPixel(10, 20, WHITE); // Draw a pixel at position (x, y). Color: WHITE
display.drawLine(0, 0, 64, 32, WHITE); // Draw a line from (x0, y0) to (x1, y1). Color: WHITE
display.drawRect(30, 30, 20, 20, WHITE); // Draw a rectangle with top-left corner (x, y), width, height. Color: WHITE
display.display(); // Update the display with the buffer contents
delay(1000); // Delay for one second
}