LCDemo Cascaded Devices
#include <LedControl.h>
/*F********************************************************************
* always have to include library
**********************************************************************/
#include "LedControl.h"
//************************* DEFINES ************************************
//************************* PROTOTYPES ************************************
//************************* VARIABLES ************************************
/*I*******************************************************
NOW NEED A lEDcONTROL TO WORK WITH.
***** THESE PIN NUMBERS WILL PROBABLY NOT WORK WITH YOUR HARDWARE *****
pin 12 is connected to the DataIn
pin 11 is connected to the CLK
pin 10 is connected to LOAD
***** PLEASE SET THE NUMBER OF DEVICES YOU HAVE *****
BUT MAXIMUM DEFAULT OF 8 MAX72XX WIL ALSO WORK.
********************************************************/
LedControl lc=LedControl( 12, 11, 10, 8);
unsigned long delaytime =500; // ALWAYS WAIT A BIT BETWEEN UPDATES OF DISPLAy
/*I*******************************************************
HAVE MORE THAN ONE DEVICE. BUT ALL OF THEM HAVE TO BE INITIALIZED INDIVIDUALLY
********************************************************/
/*F********************************************************************
*
**********************************************************************/
void
setup()
{
// ALREADY SET DEVICE CNT WHEN LEDCONTROL CREATED
int devices = lc.getDeviceCount();
for( int address = 0; address < devices; address++)// INIT ALL DEVS IN LOOP
{
lc.shutdown( address, false ); // MAX72XX STARTS IN POWER-SAVING MODE
lc.setIntensity( address, 8 ); // SET BRIGHTNESS TO A MEDIUM VALUE
lc.clearDisplay( address ); // AND CLEAR DISPLAY
}
}
/*F********************************************************************
*
**********************************************************************/
void
loop()
{
int devices=lc.getDeviceCount(); // READ NUMBER CASCADED DEVICES
// HAVE TO INIT ALL DEVICES IN A LOOP
for( int row =0; row < 8; row++)
{
for( int col = 0; col < 8; col++)
{
for( int address = 0; address < devices; address++)
{
delay( delaytime );
lc.setLed( address, row, col, true);
delay( delaytime );
lc.setLed( address, row, col, false);
}
}
}
}