Hello,
I'm trying to make a simple counter who increment every 4 seconds.
the code
// Program to demonstrate the MD_Parola library
//
// NOTE: MD_MAX72xx library must be installed and configured for the LED
// matrix type being used. Refer documentation included in the MD_MAX72xx
// library or see this link:
// https://majicdesigns.github.io/MD_MAX72XX/page_hardware.html
//
#include<CountUpDownTimer.h>
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define MAX_DEVICES 8
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
CountUpDownTimer T(UP, HIGH); // Default precision is HIGH, but you can change it to also be LOW
CountUpDownTimer T2(UP, HIGH); // Default precision is HIGH, but you can change it to also be LOW
char compteur[7];
unsigned long x = 0;
unsigned long flag = 1;
// Hardware SPI connection
MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES);
// Arbitrary output pins
// MD_Parola P = MD_Parola(DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
void setup(void)
{
Serial.begin(9600);
T.StartTimer();
T2.StartTimer();
P.begin();
sprintf (compteur, "%d", x);
P.displayText(compteur, PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
}
void loop(void)
{
T.Timer(); // run the timer
sprintf (compteur, "%d", x);
P.displayAnimate();
Serial.println (compteur);
}
work show me a 0.
But when I add my counter
void loop(void)
{
T.Timer(); // run the timer
if ( (T.ShowSeconds() - flag) == 4 )
{
flag = T.ShowSeconds();
x = x + 1 ;
sprintf (compteur, "%d", x);
};
P.displayAnimate();
Serial.println (compteur);
}
the counter doesn't work but the serial show me that x take the good value.
Using class P.displayAnimate is to pass the value at P.displayText ?
What else do I need to do ?