How can i display the hrs, mins and secs in one line on my 32x8 LEDmatrix? This is the code i have so far:
#include <MD_Parola.h>
#include <MD_MAX72XX.h>
#include <SPI.h>
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
// Hardware SPI connection
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// DEFINES
// Macros to retrieve the fractional seconds and minute parts of a time supplied in ms
#define numberOfSeconds(_time_) ((_time_ / 1000) % 60)
#define numberOfMinutes(_time_) (((_time_ / 1000) / 60) % 60)
// INCLUDES
// CONSTANTS
// GLOBALS
// 1000 ms in 1 sec, 60 secs in 1 min. So 180 mins = 1000x60x180= 10800000
unsigned long timeLimit = 10800000;
void setup() {
Serial.begin(9600);
P.begin();
}
void countdown() {
// Calculate the time remaining
unsigned long timeRemaining = timeLimit - millis();
while (timeRemaining > 0) {
// To display the time in hrs:mins:secs we need to seperate those parts
int seconds = numberOfSeconds (timeRemaining);
int minutes = numberOfMinutes (timeRemaining);
P.print(seconds);
// Update the time remaining
timeRemaining = timeLimit - millis();
}
}
void loop() {
countdown();
}
The timer works ok, i tested it with the serial monitor.
Thanks in advance!