MD_MAX72XX displaying multiple ints

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 MAX_DEVICES 4

#define CLK_PIN   13
#define DATA_PIN  11
#define CS_PIN    10

// Hardware SPI connection

// 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)




// 1000 ms in 1 sec, 60 secs in 1 min. So 180 mins = 1000x60x180= 10800000
unsigned long timeLimit = 10800000;

void setup() {

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);

    // Update the time remaining
    timeRemaining = timeLimit - millis();

void loop() {



The timer works ok, i tested it with the serial monitor.

Thanks in advance!

there are tons of examples here

have you looked at those?

Yes i did. But i can't seem to find out how i can display my ints in one line on the display.

the simple way : Build a cString (a null terminated char array) and call the displayText() method

sprintf() or better snprintf() can help

Thank you for your help. Unfortunately i don't have the knowledge to understand that. Could you give me an example on how i can attach the mins and secs in this cString?

Something like this:

char message[10]; 
int seconds = 9;
int minutes = 20;
snprintf(message, sizeof message, "%2d:%02d", minutes, seconds);  // builds "20:09"

then message is your string you can print.

here is the doc on that function:

you'll find the specifiers (how you tell the format expected for the string) in the printf() documentation

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.