/*
Now we 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
We have only a single MAX72XX.
*/
LedControl lc=LedControl(12,11,10,1);
/* we always wait a bit between updates of the display */
unsigned long delaytime=1000;
void setup() {
/*
The MAX72XX is in power-saving mode on startup,
we have to do a wakeup call
*/
lc.shutdown(0,false);
/* Set the brightness to a medium values */
lc.setIntensity(0,8);
/* and clear the display */
lc.clearDisplay(0);
}
/*
This method will display the characters for the
word "Arduino" one after the other on the matrix.
(you need at least 5x7 leds to see the whole chars)
*/
void writeArduinoOnMatrix() {
/* here is the data for the characters */
byte a[8]={B00010000 ,B00011000,B00100100,B01010100,B01010100,B01000100,B00101000,B00010000};
byte r[8]={B00000000,B00010000,B00010000,B00010000,B00010000,B00010000,B00010000,B00010000};
/* now display them one by one with a small delay */
lc.setRow(0,0,a[0]);
lc.setRow(0,1,a[1]);
lc.setRow(0,2,a[2]);
lc.setRow(0,3,a[3]);
lc.setRow(0,4,a[4]);
lc.setRow(0,5,a[5]);
lc.setRow(0,6,a[6]);
lc.setRow(0,7,a[7]);
delay(2000);
lc.setRow(0,0,r[0]);
lc.setRow(0,1,r[1]);
lc.setRow(0,2,r[2]);
lc.setRow(0,3,r[3]);
lc.setRow(0,4,r[4]);
lc.setRow(0,5,r[5]);
lc.setRow(0,6,r[6]);
lc.setRow(0,7,r[7]);
delay(500);
}
/*
This function lights up a some Leds in a row.
The pattern will be repeated on every row.
The pattern will blink along with the row-number.
row number 4 (index==3) will blink 4 times etc.
*/
void rows() {
for(int row=0;row<8;row++) {
delay(100);
lc.setRow(0,row,B10100000);
delay(100);
lc.setRow(0,row,(byte)0);
for(int i=0;i<row;i++) {
delay(100);
lc.setRow(0,row,B10100000);
delay(100);
lc.setRow(0,row,(byte)0);
}
}
}
/*
This function lights up a some Leds in a column.
The pattern will be repeated on every column.
The pattern will blink along with the column-number.
column number 4 (index==3) will blink 4 times etc.
*/
void columns() {
for(int col=0;col<8;col++) {
delay(10);
lc.setColumn(0,col,B10100000);
delay(100);
lc.setColumn(0,col,(byte)0);
for(int i=0;i<col;i++) {
delay(100);
lc.setColumn(0,col,B10100000);
delay(100);
lc.setColumn(0,col,(byte)0);
}
}
}
/*
This function will light up every Led on the matrix.
The led will blink along with the row-number.
row number 4 (index==3) will blink 4 times etc.
*/
void single() {
for(int row=0;row<8;row++) {
for(int col=0;col<8;col++) {
delay(100);
lc.setLed(0,row,col,true);
delay(100);
for(int i=0;i<col;i++) {
lc.setLed(0,row,col,false);
delay(100);
lc.setLed(0,row,col,true);
delay(100);
}
}
}
}
void loop() {
writeArduinoOnMatrix();
// rows();
// columns();
// single();
}