// Program to exercise the MD_MAX72XX library
//
// Uses most of the functions in the library
#include <MD_MAX72xx.h>
// Turn on debug statements to the serial output
#define DEBUG 1
#if DEBUG
#define PRINT(s, x) { Serial.print(F(s)); Serial.print(x); }
#define PRINTS(x) Serial.print(F(x))
#define PRINTD(x) Serial.println(x, DEC)
#else
#define PRINT(s, x)
#define PRINTS(x)
#define PRINTD(x)
#endif
// 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::PAROLA_HW
#define MAX_DEVICES 11
#define WRAPAROUND MD_MAX72XX::WRAPAROUND
#define WRAPAROUND_MODE MD_MAX72XX::ON
#define CLK_PIN 13 // or SCK
#define DATA_PIN 11 // or MOSI
#define CS_PIN 10 // or SS
// SPI hardware interface
MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// Specific SPI hardware interface
//MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, SPI1, CS_PIN, MAX_DEVICES);
// Arbitrary pins
//MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);
// We always wait a bit between updates of the display
#define DELAYTIME 500 // in milliseconds
/***********************************************************************************************************/
void cross()
// Combination of setRow() and setColumn() with user controlled
// display updates to ensure concurrent changes.
{
PRINTS("\nMoving cross");
mx.clear();
mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);
// diagonally down the display R to L
for (uint8_t i=0; i<ROW_SIZE; i++)
{
for (uint8_t j=0; j<MAX_DEVICES; j++)
{
mx.setColumn(j, i, 0xff);
mx.setRow(j, i, 0xff);
}
mx.update();
delay(DELAYTIME);
for (uint8_t j=0; j<MAX_DEVICES; j++)
{
mx.setColumn(j, i, 0x00);
mx.setRow(j, i, 0x00);
}
}
// moving up the display on the R
for (int8_t i=ROW_SIZE-1; i>=0; i--)
{
for (uint8_t j=0; j<MAX_DEVICES; j++)
{
mx.setColumn(j, i, 0xff);
mx.setRow(j, ROW_SIZE-1, 0xff);
}
mx.update();
delay(DELAYTIME);
for (uint8_t j=0; j<MAX_DEVICES; j++)
{
mx.setColumn(j, i, 0x00);
mx.setRow(j, ROW_SIZE-1, 0x00);
}
}
// diagonally up the display L to R
for (uint8_t i=0; i<ROW_SIZE; i++)
{
for (uint8_t j=0; j<MAX_DEVICES; j++)
{
mx.setColumn(j, i, 0xff);
mx.setRow(j, ROW_SIZE-1-i, 0xff);
}
mx.update();
delay(DELAYTIME);
for (uint8_t j=0; j<MAX_DEVICES; j++)
{
mx.setColumn(j, i, 0x00);
mx.setRow(j, ROW_SIZE-1-i, 0x00);
}
}
mx.control(MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
}
/*
*/
/***********************************************************************************************************/
void setup()
{
#if DEBUG
Serial.begin(57600);
#endif
PRINTS("\n[MD_MAX72XX Test & Demo]");
if (!mx.begin())
PRINTS("\nMD_MAX72XX initialization failed");
}
/***********************************************************************************************************/
void loop()
{
//scrollText("Ali Dadashpoor");
//zeroPointSet();
//rows();
//columns();
cross();
/*stripe();
checkboard();
bullseye();
bounce();
spiral();
scrollText("Control");
intensity();
scanLimit();
blinking();
scrollText("Transform");
transformation1();
transformation2();
scrollText("Charset");
wrapText();
showCharset();
*/
}