LED Cascade
/*H********************************************************************
MAX72xx LedControl
***** These pin numbers will probably not work with your hardware *****
pin 12 is connected to DataIn
pin 11 is connected to CLK
pin 10 is connected to LOAD
***** Please set number of devices you have *****
But maximum default of 8 MAX72XX wil also work.
**********************************************************************/
#include "LedControl.h" // HAVE TO INCLUDE LIBRARY
//************************* DEFINES ************************************
//************************* PROTOTYPES ************************************
//************************* VARIABLES ************************************
LedControl Lctl = LedControl( 12, 11, 10, 8 );
unsigned long DlyTim = 500; // WAIT A BIT BETWEEN DSPLY UPDTS
/*F********************************************************************
* Cascaded LED Matrices:
have more than one device. But all of them have to be initialized individually.
**********************************************************************/
void
setup()
{
// ALREADY SET DEVICES COUNT WHEN CREATED LEDCONTROl
int devices = Lctl.getDeviceCount();
// HAVE TO INIT DEVICES IN LOOP
for( int address =0; address < devices; address++ )
{ // MAX72XX IN POWER-SAVING MODE ON STARTUP
Lctl.shutdown( address, false );
Lctl.setIntensity( address, 8); // SET BRIGHTNESS TO MEDIUM VALUE
Lctl.clearDisplay( address ); // AND CLEAR DISPLAY
}
}
/*F********************************************************************
*
**********************************************************************/
void
loop()
{
int devices = Lctl.getDeviceCount(); // READ NUMBER CASCADED DEVICES
for( int row =0; row < 8; row++) // INIT ALL DEVICES IN LOOP
{
for( int col =0; col < 8; col++)
{
for( int address =0; address < devices; address++)
{
delay( DlyTim );
Lctl.setLed( address, row, col, true );
delay( DlyTim );
Lctl.setLed( address, row, col, false );
}
}
}
}