#include <Wire.h>
#include <RTClib.h>
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 4
#define CLK_PIN 21
#define DATA_PIN 23
#define CS_PIN 22
RTC_DS1307 rtc;
MD_Parola matrix = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
void setup() {
Serial.begin(9600);
Wire.begin(15, 2); // Inicia la comunicación I2C en los pines SDA y SCL específicos
rtc.begin();
if (!rtc.isrunning()) {
Serial.println("RTC is NOT running!");
// Si la RTC no está funcionando, debes establecerla con una hora fija.
// De lo contrario, siempre mostrará la hora de inicio.
}
}
void loop() {
DateTime now = rtc.now();
int hour = now.hour();
int minute = now.minute();
int second = now.second();
// Formatea la hora para mostrarla en el panel LED
char timeString[9]; // HH:MM:SS
sprintf(timeString, "%02d:%02d:%02d", hour, minute, second);
matrix.displayText(timeString, PA_CENTER, 50, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
delay(1000); // Actualiza cada segundo
}