Like I said in the title, I am using a DS3231 real time clock module and 4 cascaded FC-16 modules(they are basically MAX7219 led matrices based modules). My goal is to display a timetable, a schedule for a classroom on the matrices. The purpose of the DS3231 module is to keep track of time(mainly hours) from 8:00AM to 20:00PM, to display the hour on the matrix and to change the subject when it hits even hours. Eg: when it's 8:00AM we have subject A, when it's 10:00AM we have subject B etc
And after that I have to use a ESP8266 wifi module to change the schedule from distance.
EDIT1: I managed to display the hour on the matrix, but now I really can't figure out how to display the text in 4 rows. I have 4 FC-16 modules and I want to put each of them on top of the other so I can have 4 rows of text. I managed to do this by inserting space between words but this is not optimal. I want this to be automated so the person changing the text in the program doesn't have to do the spacing thing by themselves.
#include "RTClib.h"
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
const uint16_t WAIT_TIME = 1000;
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 16
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
RTC_DS3231 rtc;
//char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
void setup () {
P.begin();
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
if (rtc.lostPower()) {
Serial.println("RTC lost power, lets set the time!");
// If the RTC have lost power it will set the RTC to the date & time this sketch was compiled in the following line
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
}
void loop () {
DateTime now = rtc.now();
char buffer[] = "hh:mm"; // hours and minutes
P.print(now.toString(buffer)); // display
// Serial.println();
delay(1000);
}```
rtc.adjust()
line. Are you sure your RTC is correctly initialized? If not, the returnedDateTime
can be invalid, which could result in garbage being printed out. You can also check the value returned bynow.isValid()
.