Hello,
I would appreciate someone assisting me with some code.
I am using an Arduino Uno to control a MAX72CC matrix display. The code below works well but I would like to modify it such that the message that appears across the display can vary depending upon certain conditions as defined in an if statement placed within the loop(). I have not had much luck doing this. Could someone assist me? Following is the code.
Thank you in advance for your assistance.
"
//**************************
//
// MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
//
#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 HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 8
#define PAUSE_TIME 5000
#define SCROLL_SPEED 50
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
//char Day = "Monday";
// HARDWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// SOFTWARE SPI
//MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
char *msg[] = // I WOULD LIKE TO BE ABLE TO MOVE THESE 5 LINES OF CODE DOWN INTO THE LOOP
{
"ABCDEFGHIJK",
"01234567890",
};
void setup(void)
{
// initialise the LED display
P.begin();
P.setZoneEffect(0, true, PA_FLIP_LR);
}
void loop(void)
// I WOULD LIKE TO PUT THE MSG[] HERE IN THE LOOP AS PART OF AN IF STATEMENT SO THE MESSAGE
// COULD CHANGE DEPENDING UPON CERTAIN CONDITIONS AS SPECIFIED IN THE IF STATEMENT.
// HOWEVER, PUTTING THE MSG[] HERE CAUSES AN ERROR.
{
static uint8_t cycle = 0;
if (P.displayAnimate())
{
// set up the string
P.displayText(msg[cycle], PA_CENTER, SCROLL_SPEED, PAUSE_TIME, PA_PRINT, PA_NO_EFFECT);
// prepare for next pass
cycle = (cycle + 1) % ARRAY_SIZE(msg);
}
}
"