Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LedControl.h>
- /*
- pin 2 is connected to the DataIn
- pin 4 is connected to the CLK
- pin 3 is connected to LOAD
- ***** Please set the number of devices you have *****
- */
- LedControl lc=LedControl(23, 28, 29, 2);
- const int addrL = 0; // first LED matrix
- const int addrR = 1; // second LED matrix
- const unsigned long delaytime = 400;
- const byte IMAGES[][8] = {
- {B00000000,
- B00000000,
- B00000000,
- B10000000,
- B00000000,
- B00000000,
- B00000000,
- B00000000},
- {B00000000,
- B00000000,
- B10000000,
- B11000000,
- B10000000,
- B00000000,
- B00000000,
- B00000000},
- {B00000000,
- B10000000,
- B11000000,
- B11100000,
- B11000000,
- B10000000,
- B00000000,
- B00000000},
- {B00000000,
- B01000000,
- B11100000,
- B11110000,
- B11100000,
- B01000000,
- B00000000,
- B00000000},
- {B00000000,
- B00100000,
- B11110000,
- B11111000,
- B11110000,
- B00100000,
- B00000000,
- B00000000},
- {B00000000,
- B00010000,
- B11111000,
- B11111100,
- B11111000,
- B00010000,
- B00000000,
- B00000000},
- {B00000000,
- B00001000,
- B01111100,
- B01111110,
- B01111100,
- B00001000,
- B00000000,
- B00000000},
- {B00000000,
- B00000100,
- B00111110,
- B00111111,
- B00111110,
- B00000100,
- B00000000,
- B00000000},
- {B00000000,
- B00000010,
- B00011111,
- B00011111,
- B00011111,
- B00000010,
- B00000000,
- B00000000},
- {B00000000,
- B00000001,
- B00001111,
- B00001111,
- B00001111,
- B00000001,
- B00000000,
- B00000000},
- {B00000000,
- B00000000,
- B00000111,
- B00000111,
- B00000111,
- B00000000,
- B00000000,
- B00000000},
- {B00000000,
- B00000000,
- B00000011,
- B00000011,
- B00000011,
- B00000000,
- B00000000,
- B00000000},
- {B00000000,
- B00000000,
- B00000001,
- B00000001,
- B00000001,
- B00000000,
- B00000000,
- B00000000},
- {B00000000,
- B00000000,
- B00000000,
- B00000000,
- B00000000,
- B00000000,
- B00000000,
- B00000000}};
- const int IMAGES_LEN = sizeof(IMAGES) / 8;
- const byte right[8] = {
- B00000000,
- B00110000,
- B01001000,
- B01011100,
- B01011010,
- B01000010,
- B00111100,
- B00000000};
- void setup() {
- /*The MAX72XX is in power-saving mode on startup*/
- lc.shutdown(addrL,false);
- lc.shutdown(addrR,false);
- /* Set the brightness to max values */
- lc.setIntensity(addrL,15);
- lc.setIntensity(addrR,15);
- /* and clear the display */
- lc.clearDisplay(addrL);
- lc.clearDisplay(addrR);
- }
- void showLeft() {
- for (int i = 0; i < 14; i++) {
- for (int j = 0; j < 8; j++) {
- lc.setRow(0, j, IMAGES[i][j]);
- }
- }
- }
- void showRight() {
- displayRight(right);
- }
- void displayRight(byte right[8]) {
- lc.clearDisplay(addrR);
- for(int row=0;row<8;row++) {
- lc.setRow(addrR,row,right[row]);
- }
- }
- void loop() {
- showLeft();
- showRight();
- delay(delaytime);
- }
Advertisement
Add Comment
Please, Sign In to add comment