#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
// The parameter -1 indicates that the display does not have a physical reset pin
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup() {
// Initialize with the I2C address 0x3C (common default for these displays)
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
display.clearDisplay(); // Clear the buffer
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0, 10); // Start at top-left corner
display.println(F("Hello, Arduino!"));
display.println(F("OLED Display OK"));
display.display();
display.clearDisplay();
delay(2000);
display.println(F("Rio de Janeiro!"));
display.println(F("VascoooooOOOOO"));
display.display(); // Actually push everything to the screen
}
void loop() {
// Put your main code here, to run repeatedly:
}