Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include <TimeLib.h>
- #include <DS1307RTC.h>
- //#include <SPI.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)
- Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire);
- void setup()
- {
- display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
- }
- void loop()
- {
- tmElements_t tm;
- display.clearDisplay();
- if (RTC.read(tm)) {
- lcdDraw(tm.Hour, 20, 25, 10, 8, 3, 5);
- lcdDraw(tm.Minute, 11, 5, 33, 5, 2, 10);
- lcdDraw(tm.Second, 11, 5, 55, 5, 2, 10);
- display.display();
- }
- delay(1000);
- }
- void lcdDraw(byte timeis, byte x1, byte x2, byte y, byte d1, byte d2, byte d3) {
- byte a = timeis / d3; int b = timeis % d3;
- for (byte i = 0; i < a; i++) {
- display.drawCircle(i * x1 + x2, y, d1, SSD1306_WHITE);
- }
- for (byte i = 0; i < b; i++) {
- display.fillCircle(i * x1 + x2, y, d2, SSD1306_INVERSE);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement