#include <MD_MAX72xx.h>
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 1
#define CLK_PIN 13 // or SCK
#define DATA_PIN 11 // or MOSI
#define CS_PIN 10 // or SS
MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
void scrollText(const char *p)
{
uint8_t charWidth;
uint8_t cBuf[8]; // this should be ok for all built-in fonts
uint8_t tempWidth;
while (*p != '\0')
{
charWidth = mx.getChar(*p++, sizeof(cBuf) / sizeof(cBuf[0]), cBuf);
tempWidth += charWidth + 1;
for (uint8_t i = 0; i <= charWidth; i++) // allow space between characters
{
mx.transform(MD_MAX72XX::TSL);
mx.setColumn(0, (i < charWidth) ? cBuf[i] : 0);
delay(50);
}
}
}
void setup() {
Serial.begin(115200);
mx.begin();
mx.control(MD_MAX72XX::INTENSITY, 0);
Serial.println("Hello, let's test...");
}
void loop() {
Serial.println("Checking column pixels");
for (uint8_t col = 0; col < 8; col ++) {
for (uint16_t dot = 1; dot < 256; dot = dot * 2) {
mx.setColumn(col, dot);
Serial.print(col);
Serial.print(",");
Serial.println(dot);
delay(200);
}
mx.setColumn(col,0);
}
Serial.println("Checking row pixels");
for (uint8_t row = 0; row < 8; row ++) {
for (uint16_t dot = 1; dot < 256; dot = dot * 2) {
mx.setRow(row, dot);
Serial.print(row);
Serial.print(",");
Serial.println(dot);
delay(200);
}
mx.setRow(row,0);
}
for (uint8_t i = 0; i < 8; i ++) {
mx.setColumn(i,255);
}
delay(1000);
mx.clear();
delay(1000);
scrollText("Test Complete ");
delay(1000);
}