#include <TM1638plus.h>
#include <DS3231.h>
#include <Wire.h>
const int CLK = 6;
const int STB = 4;
const int DIO = 7;
bool high_freq = false;
TM1638plus tm(STB, CLK, DIO, high_freq);
RTClib myRTC;
void setup() {
Serial.begin(57600);
Wire.begin();
tm.displayBegin();
tm.brightness(1);
}
unsigned int counter = 0;
void loop() {
delay(1000);
Time();
//Counter();
Display();
}
void Time() {
DateTime now = myRTC.now();
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
}
void Counter() {
tm.displayHex(0, (counter / 10000000) % 10);
tm.displayHex(1, (counter / 1000000) % 10);
tm.displayHex(2, (counter / 100000) % 10);
tm.displayHex(3, (counter / 10000) % 10);
tm.displayHex(4, (counter / 1000) % 10);
tm.displayHex(5, (counter / 100) % 10);
tm.displayHex(6, (counter / 10) % 10);
tm.displayHex(7, counter % 10);
counter++;
if (counter == 100000000) {
counter = 0;
}
}
void Display() {
DateTime now = myRTC.now();
tm.displayIntNum((now.hour(), DEC, now.minute(), DEC), true, TMAlignTextRight);
}