I have just finished this project and thought I would share it. I thought it maybe quite useful. If anyone can see anyway enhance this project or improve the sketch please let me know. Also after the display scrolls I would like it to stop for a few seconds, how would I do that?
#include <MD_Parola.h>
#include <SPI.h>
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CS_PIN 10
#define CLK_PIN 13
#define DIN_PIN 11
#define SPEED 50
MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
#define buttonPin A0
bool buttonVal;
bool buttonState;
bool messageState = 0;
bool lastButtonState = 1;
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 50;
void setup() {
myDisplay.begin();
myDisplay.setIntensity(4);
myDisplay.displayClear();
pinMode(buttonPin, INPUT_PULLUP);
}
void DisplayMessage(char msg[]) {
if (myDisplay.displayAnimate()) {
myDisplay.displayScroll(msg, PA_CENTER, PA_SCROLL_LEFT, SPEED);
myDisplay.displayReset();
}
}
void loop() {
buttonVal = digitalRead(buttonPin);
if (buttonVal != lastButtonState) {
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
if (buttonVal != buttonState) {
buttonState = buttonVal;
if (buttonState == 0) {
messageState = !messageState;
}
}
}
if (messageState == 0) {
DisplayMessage("Andy is IN");
}
if (messageState == 1) {
DisplayMessage("Andy is OUT");
}
lastButtonState = buttonVal;
}