//https://www.youtube.com/channel/UCIfxsufwrJH9PWdUjzO3JGA

#include <RTClib.h>
#include <TM1637Display.h>

#define CLK 10
#define DIO 9

RTC_DS3231 rtc;
TM1637Display display = TM1637Display(CLK, DIO);
void setup() {
  Serial.begin(9600);
  delay(3000);
  rtc.adjust(DateTime(2022, 9, 17, 21, 21, 0));
  if (! rtc.begin()) {
    Serial.println("Couldn't find RTC");
    while (1);
  }
  if (rtc.lostPower()) {
    Serial.println("RTC lost power, lets set the time!");
    rtc.adjust(DateTime("Set The Time"));   //Set The Time   Set The Time   Set The Time   Set The Time   Set The Time   Set The Time   Set The Time
    // This line sets the RTC with an explicit date & time, for example to set
    // January 21, 2014 at 3am you would call:
    //rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
  }
  display.setBrightness(7);
  // Clear the display:
  display.clear();
}

void loop() {
  DateTime now = rtc.now();
  int displaytime = (now.hour() * 100) + now.minute();
  Serial.println(displaytime);
  display.showNumberDecEx(displaytime, 0b11100000, true);
  delay(1000);
  display.showNumberDec(displaytime, true);
  delay(1000);
}
