Untitled
unknown
plain_text
14 days ago
1.2 kB
5
Indexable
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
// --- FIXED HARDWARE CONFIGURATION FOR PHYSICAL MODULE ---
// GENERIC_HW reverses the default data block direction, which fixes mirroring.
#define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW
#define MAX_DEVICES 4
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
int minutes = 5;
int seconds = 0;
unsigned long lastUpdateTime = 0;
char timerString[6];
void setup() {
P.begin();
P.setIntensity(5);
P.displayClear();
P.setTextAlignment(PA_CENTER);
// No software zone effects needed here yet!
// Let the GENERIC_HW driver do the heavy lifting first.
updateTimerDisplay();
}
void loop() {
if (millis() - lastUpdateTime >= 1000) {
lastUpdateTime = millis();
if (seconds == 0) {
if (minutes == 0) {
P.print("BOOM");
while(true);
} else {
minutes--;
seconds = 59;
}
} else {
seconds--;
}
updateTimerDisplay();
}
}
void updateTimerDisplay() {
sprintf(timerString, "%02d:%02d", minutes, seconds);
P.print(timerString);
}Editor is loading...
Leave a Comment