Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
955 B
15
Indexable
Never
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

#define MAX_DEVICES 4
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define CLK_PIN 52
#define DATA_PIN 51
#define CS_PIN 53
int hallSensorPin = 2;
volatile bool sensorTriggered = false;
MD_Parola myDisplay = MD_Parola(MD_MAX72XX::FC16_HW, CS_PIN, MAX_DEVICES);

void sensorInterrupt() {
  sensorTriggered = !digitalRead(hallSensorPin); // Read the sensor state in the interrupt
}

void setup() {
  myDisplay.begin();
  myDisplay.setIntensity(8);
  myDisplay.displayClear();
  pinMode(hallSensorPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(hallSensorPin), sensorInterrupt, FALLING); // Attach interrupt on CHANGE
}

void loop() {
  if (sensorTriggered) {
    myDisplay.displayScroll("STOP STOP STOP STOP ", PA_CENTER, PA_SCROLL_RIGHT, 30);
    sensorTriggered = false;
  }
  if (myDisplay.displayAnimate()) {
    myDisplay.displayClear();
  }
}
Leave a Comment