miklik

LDE8x8_I2C

May 29th, 2019
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.16 KB | None | 0 0
  1. #include <LedControl.h>
  2.  
  3. /*
  4.  pin 2 is connected to the DataIn
  5.  pin 4 is connected to the CLK
  6.  pin 3 is connected to LOAD
  7.  ***** Please set the number of devices you have *****
  8.  */
  9. LedControl lc=LedControl(23, 28, 29, 2);
  10.  
  11. const int addrL = 0;  // first LED matrix
  12. const int addrR = 1;  // second LED matrix
  13. const unsigned long delaytime = 400;
  14. const byte IMAGES[][8] = {
  15.     {B00000000,
  16.      B00000000,
  17.      B00000000,
  18.      B10000000,
  19.      B00000000,
  20.      B00000000,
  21.      B00000000,
  22.      B00000000},
  23.     {B00000000,
  24.      B00000000,
  25.      B10000000,
  26.      B11000000,
  27.      B10000000,
  28.      B00000000,
  29.      B00000000,
  30.      B00000000},
  31.     {B00000000,
  32.      B10000000,
  33.      B11000000,
  34.      B11100000,
  35.      B11000000,
  36.      B10000000,
  37.      B00000000,
  38.      B00000000},
  39.     {B00000000,
  40.      B01000000,
  41.      B11100000,
  42.      B11110000,
  43.      B11100000,
  44.      B01000000,
  45.      B00000000,
  46.      B00000000},
  47.     {B00000000,
  48.      B00100000,
  49.      B11110000,
  50.      B11111000,
  51.      B11110000,
  52.      B00100000,
  53.      B00000000,
  54.      B00000000},
  55.     {B00000000,
  56.      B00010000,
  57.      B11111000,
  58.      B11111100,
  59.      B11111000,
  60.      B00010000,
  61.      B00000000,
  62.      B00000000},
  63.     {B00000000,
  64.      B00001000,
  65.      B01111100,
  66.      B01111110,
  67.      B01111100,
  68.      B00001000,
  69.      B00000000,
  70.      B00000000},
  71.     {B00000000,
  72.      B00000100,
  73.      B00111110,
  74.      B00111111,
  75.      B00111110,
  76.      B00000100,
  77.      B00000000,
  78.      B00000000},
  79.     {B00000000,
  80.      B00000010,
  81.      B00011111,
  82.      B00011111,
  83.      B00011111,
  84.      B00000010,
  85.      B00000000,
  86.      B00000000},
  87.     {B00000000,
  88.      B00000001,
  89.      B00001111,
  90.      B00001111,
  91.      B00001111,
  92.      B00000001,
  93.      B00000000,
  94.      B00000000},
  95.     {B00000000,
  96.      B00000000,
  97.      B00000111,
  98.      B00000111,
  99.      B00000111,
  100.      B00000000,
  101.      B00000000,
  102.      B00000000},
  103.     {B00000000,
  104.      B00000000,
  105.      B00000011,
  106.      B00000011,
  107.      B00000011,
  108.      B00000000,
  109.      B00000000,
  110.      B00000000},
  111.     {B00000000,
  112.      B00000000,
  113.      B00000001,
  114.      B00000001,
  115.      B00000001,
  116.      B00000000,
  117.      B00000000,
  118.      B00000000},
  119.     {B00000000,
  120.      B00000000,
  121.      B00000000,
  122.      B00000000,
  123.      B00000000,
  124.      B00000000,
  125.      B00000000,
  126.      B00000000}};
  127.  
  128. const int IMAGES_LEN = sizeof(IMAGES) / 8;
  129.  
  130. const byte right[8] = {
  131.     B00000000,
  132.     B00110000,
  133.     B01001000,
  134.     B01011100,
  135.     B01011010,
  136.     B01000010,
  137.     B00111100,
  138.     B00000000};
  139.  
  140. void setup() {
  141.   /*The MAX72XX is in power-saving mode on startup*/
  142.   lc.shutdown(addrL,false);
  143.   lc.shutdown(addrR,false);
  144.   /* Set the brightness to max values */
  145.   lc.setIntensity(addrL,15);
  146.   lc.setIntensity(addrR,15);
  147.   /* and clear the display */
  148.   lc.clearDisplay(addrL);
  149.   lc.clearDisplay(addrR);
  150. }
  151.  
  152. void showLeft() {  
  153.   for (int i = 0; i < 14; i++) {
  154.     for (int j = 0; j < 8; j++) {
  155.       lc.setRow(0, j, IMAGES[i][j]);
  156.     }  
  157.   }
  158. }
  159.  
  160. void showRight() {
  161.   displayRight(right);
  162. }
  163.  
  164. void displayRight(byte right[8]) {
  165.   lc.clearDisplay(addrR);
  166.   for(int row=0;row<8;row++) {
  167.     lc.setRow(addrR,row,right[row]);
  168.   }
  169. }
  170.  
  171. void loop() {
  172.   showLeft();
  173.   showRight();
  174.   delay(delaytime);
  175. }
Advertisement
Add Comment
Please, Sign In to add comment