#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include "RTClib.h"
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 5 // Define the number of displays connected
#define CLK_PIN 52 // CLK or SCK
#define DATA_PIN 51 // DATA or MOSI
#define CS_PIN 53 // CS or SS
int hour, minute, second;
DateTime current;
// Hardware SPI connection
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
RTC_DS1307 rtc; //create an instant of RTC
void setup() {
Serial.begin(115200);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
Serial.flush();
abort();
}
P.begin();
P.setSpeed(10); //setting the speed to 10
P.setPause(100); //setting the pause to 100
P.setTextAlignment( PA_CENTER);//setting the txt allignment
}
void loop() {
current = rtc.now(); //get the current time
Find_time(current);
String Time, colon;
colon = ":";
//Typecasting the integer value of hour minute and seconds from rtc to string
//and merging them together to form one string using +
Time = String(hour) + colon + String(minute) + colon + String(second);
P.print(Time);
}
void Find_time(DateTime now) {
hour = now.hour(); //get current hour
minute = now.minute(); //get current minute
second = now.second(); //get current second
}