#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED width, in pixels
#define SCREEN_HEIGHT 64 // OLED height, in pixels
// create an OLED display object connected to I2C
Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
int segundos = 0;
int minutos = 0;
void setup() {
Serial.begin(9600);
// initialize OLED display with I2C address 0x3C
if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("failed to start SSD1306 OLED"));
while (1);
}
delay(2000); // wait two seconds for initializing
oled.clearDisplay(); // clear display
oled.setTextColor(WHITE); // set text color
}
void loop() {
oled.setTextSize(1);
oled.setCursor(20, 2);
oled.println("Bom dia"); // dependendo da hora pode ser mostrado msgs diferentes
oled.setTextSize(2);
oled.setCursor(100, 40);
oled.println(segundos);
oled.setCursor(88, 40);
oled.println(":");
oled.setCursor(64, 40);
oled.println(minutos);
oled.display();
segundos++;
if(segundos >= 60){
segundos = 0;
minutos++;
}
delay(5);
oled.clearDisplay();
}