Max7219 Parola print_test 1 sentence program

Dear all,

I need your help, currently I am using arduino uno, connect with Max7219 4 in 1 display, with additional
button use as a counter, every time button is press it will count 1.

I am using parola print_test, i want to know how to make the display become like this:
“Door 1: 1 times” in one sentence, instead of it showing each word “Door 1”, “1”, “time” one by one in display.

Thanks for the help

#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

#define button1 5
#define button2 6
#define resetbutton 7
int counterA=0;
int counterB=0;
int sum=0;
// Define hardware type, size, and output pins:
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 8
#define CS_PIN 3
// Create a new instance of the MD_Parola class with hardware SPI connection:
//MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// Setup for software SPI:
#define DATA_PIN 2
#define CLK_PIN 4
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
void setup() {
int press1;
int val;
pinMode(button1, INPUT);
pinMode(button2, INPUT);
pinMode(resetbutton, INPUT);
// Intialize the object:
myDisplay.begin();
// Set the intensity (brightness) of the display (0-15):
myDisplay.setIntensity(0);
// Clear the display:
myDisplay.displayClear();
}
void loop() {

if(button1==HIGH)
{
counterA++;
}
if(button2==HIGH)
{
counterB++;
}
if(resetbutton==HIGH)
{
counterA=0;
counterB=0;
}
int sum =counterA+counterB;
myDisplay.setTextAlignment(PA_LEFT);
myDisplay.print("DOOR1: ");
delay(2000);
myDisplay.setTextAlignment(PA_CENTER);
myDisplay.print(counterA);
delay(2000);
myDisplay.setTextAlignment(PA_CENTER);
myDisplay.print(“Time”);
delay(2000);
myDisplay.setTextAlignment(PA_CENTER);
myDisplay.print("DOOR2: ");
delay(2000);
myDisplay.setTextAlignment(PA_CENTER);
myDisplay.print(counterB);
delay(2000);
myDisplay.setTextAlignment(PA_CENTER);
myDisplay.print(“Time”);
delay(2000);

myDisplay.setTextAlignment(PA_CENTER);
myDisplay.print(“Total:”);
delay(2000);
myDisplay.setTextAlignment(PA_CENTER);
myDisplay.print(sum);
delay(2000);
myDisplay.setTextAlignment(PA_CENTER);
myDisplay.print(“Time”);
delay(2000);
}

Please use the code tags </> rather than quote to display your code. You can edit the post to correct this.

You need to investigate the sprintf() function to format your information into one string before printing.

Also, you don’t need to set the alignment for the text every time, just do it once when it changes.