Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //We always have to include the library
- #include "LedControl.h"
- /*
- Now we need a LedControl to work with.
- PD0 is connected to the DataIn
- PD1 is connected to the CS
- PD2 is connected to CLK
- ***** Please set the number of devices you have *****
- But the maximum default of 8 MAX72XX wil also work.
- */
- LedControl lc=LedControl(23,25,24,4);
- /* we always wait a bit between updates of the display */
- unsigned long delaytime=125;
- /*
- This time we have more than one device.
- But all of them have to be initialized
- individually.
- */
- void setup() {
- //we have already set the number of devices when we created the LedControl
- int devices=lc.getDeviceCount();
- //we have to init all devices in a loop
- for(int address=0;address<devices;address++) {
- /*The MAX72XX is in power-saving mode on startup*/
- lc.shutdown(address,false);
- /* Set the brightness to a medium values */
- lc.setIntensity(address,8);
- /* and clear the display */
- lc.clearDisplay(address);
- }
- }
- void loop() {
- //read the number cascaded devices
- int devices=lc.getDeviceCount();
- int rowOn=4, rowOff=0;
- //we have to init all devices in a loop
- // for(int col=0;col<8;col++) {
- int col=7;
- int address=0;
- lc.setLed(address,0,col,true);
- lc.setLed(address,1,col,true);
- lc.setLed(address,2,col,true);
- for(int rowCount=0;rowCount<10;rowCount+=1) {
- // for(int address=0;address<devices;address++) {
- // delay(delaytime);
- if (rowCount<5){
- rowOn=rowCount+3;
- rowOff=rowCount;
- } else {
- rowOn=9-rowCount;
- rowOff=12-rowCount;
- }
- lc.setLed(address,rowOn,col,true);
- lc.setLed(address,rowOff,col,false);
- delay(delaytime);
- if(rowCount==9){
- rowCount=-1;
- col=col-1;
- if(col==-1){
- delaytime=delaytime/2;
- col=7;
- address=address+1;
- if(address==4){
- for(int rowClear=0;rowClear<8;rowClear++) {
- for(int addressClear=4;addressClear>-1;addressClear--) {
- for(int colClear=0;colClear<8;colClear++) {
- lc.setLed(addressClear,rowClear,colClear,false);
- // delay(delaytime);
- }
- }
- }
- delaytime=125;
- break;
- }
- }
- lc.setLed(address,0,col,true);
- lc.setLed(address,1,col,true);
- lc.setLed(address,2,col,true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement