/*
Q3. Connect DS1307 RTC and LED Matrix with “chain”
attribute is 5 to Arduino Mega. Write a code to display
the current time from DS1307 RTC to LED Matrix with
the speed value is 10, pause value is 100, and text
alignment is PA_CENTER. (require demonstration)
*/
// Header file includes
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#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
// Hardware SPI connection
MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
#include "RTClib.h"
RTC_DS1307 rtc;
//int hour, minute, second =0;
int hour, minute, second;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
P.begin();
if(!rtc.begin())
{
Serial.println("Coudn't find RTC");
Serial.flush();
abort();
}
}
void loop() {
// put your main code here, to run repeatedly:
DateTime now=rtc.now();
hour=now.hour();
minute = now.minute();
second=now.second();
String MyClk=String(hour)+":"+ String(minute)+":"+String(second);
Serial.print("Time: ");
Serial.println(MyClk);
char *strClk = MyClk.c_str();
/*
int length=txt.length()+1;
char txt1(length);
txt.toCharArray (txt1,length);
*/
if (P.displayAnimate())
{
//P.displayText(strClk , PA_CENTER, 10, 100, PA_SCROLL_LEFT);
P.displayText(strClk, PA_CENTER, 10, 100, PA_PRINT, PA_NO_EFFECT);
}
}