// Program to demonstrate the MD_Parola library
// button select canned messages
// MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
// by groundFungus AKA c. goulding
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
const byte buttonPin = 2; // the pin that the pushbutton is attached to
// 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::FC16_HW
#define MAX_DEVICES 4
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
// individual messages in strings
const char msg_1[] = "1111";
const char msg_2[] = "2222";
const char msg_3[] = "3333";
const char msg_4[] = "4444";
const char msg_5[] = "5555";
const char msg_6[] = "6666";
// an array of pointers to the strings
char *messages[] = {msg_1, msg_2, msg_3, msg_4, msg_5, msg_6};
byte messageNum = sizeof(messages) / sizeof(messages[0]);
int counter = 0; // counter for the number of button presses
//-------------------------------------------------------------------
void setup(void)
{
Serial.begin(115200);
Serial.println("\nParola pick a message program\n");
P.begin();
pinMode(buttonPin, INPUT_PULLUP);
}
//-------------------------------------------------------------------
void loop()
{
while (digitalRead(buttonPin) == LOW) {
if (digitalRead(buttonPin) == HIGH)
{
for (counter = 0; counter < 4096; counter++)
{
if (P.displayAnimate()) // time to show next frame?
{
P.displayText(messages[counter], PA_CENTER, 30, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
}
}
P.begin();
}
}
}