sweetboicz

led matrix scroll

May 4th, 2022
852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.57 KB | None | 0 0
  1. #include <WEMOS_Matrix_LED.h>
  2.  
  3. byte nums[] =
  4. {
  5.   B11100000, //-- 0
  6.   B10100000,
  7.   B10100000,
  8.   B10100000,
  9.   B10100000,
  10.   B10100000,
  11.   B10100000,
  12.   B11100000,
  13.   B00100000, //-- 1
  14.   B00100000,
  15.   B01100000,
  16.   B00100000,
  17.   B00100000,
  18.   B00100000,
  19.   B00100000,
  20.   B00100000,
  21.   B11100000, //-- 2
  22.   B00100000,
  23.   B00100000,
  24.   B11100000,
  25.   B10000000,
  26.   B10000000,
  27.   B10000000,
  28.   B11100000,
  29.   B11100000, //-- 3
  30.   B00100000,
  31.   B00100000,
  32.   B11100000,
  33.   B00100000,
  34.   B00100000,
  35.   B00100000,
  36.   B11100000,
  37.   B10100000, //-- 4
  38.   B10100000,
  39.   B10100000,
  40.   B11100000,
  41.   B00100000,
  42.   B00100000,
  43.   B00100000,
  44.   B00100000,
  45.   B11100000, //-- 5
  46.   B10000000,
  47.   B10000000,
  48.   B11100000,
  49.   B00100000,
  50.   B00100000,
  51.   B00100000,
  52.   B11100000,
  53.   B11100000, //-- 6
  54.   B10000000,
  55.   B10000000,
  56.   B11100000,
  57.   B10100000,
  58.   B10100000,
  59.   B10100000,
  60.   B11100000,
  61.   B11100000, //-- 7
  62.   B00100000,
  63.   B00100000,
  64.   B00100000,
  65.   B00100000,
  66.   B00100000,
  67.   B00100000,
  68.   B00100000,
  69.   B11100000, //-- 8
  70.   B10100000,
  71.   B10100000,
  72.   B11100000,
  73.   B10100000,
  74.   B10100000,
  75.   B10100000,
  76.   B11100000,
  77.   B11100000, //-- 9
  78.   B10100000,
  79.   B10100000,
  80.   B11100000,
  81.   B00100000,
  82.   B00100000,
  83.   B00100000,
  84.   B11100000
  85. };
  86.  
  87. byte workbyte[] =
  88. {
  89.   B00000000,
  90.   B00000000,
  91.   B00000000,
  92.   B00000000,
  93.   B00000000,
  94.   B00000000,
  95.   B00000000,
  96.   B00000000
  97. };
  98.  
  99. byte matrix[] =
  100. {
  101.   B00000000,
  102.   B00000000,
  103.   B00000000,
  104.   B00000000,
  105.   B00000000,
  106.   B00000000,
  107.   B00000000,
  108.   B00000000
  109. };
  110. byte d = B00000000;
  111. byte charlength = 4;
  112. int firstNum = 0;
  113. int maxRight = 11;
  114. int nChars = 2;
  115.  
  116. MLED mled(1); //set intensity=5
  117.  
  118. void setup()
  119. {
  120.   Serial.begin(9600);
  121.   mled.clear();
  122. }
  123.  
  124. void loop()
  125. {
  126.   int sh = 7; //-- shit right
  127.   int shl = 0;//-- shift left
  128.  
  129.   charByte(firstNum);
  130.    
  131.   for(int x = 0; x < maxRight; x++)
  132.   {
  133.     for(int y = 0; y < 8; y++)
  134.     {
  135.       d = workbyte[y];
  136.      
  137.       if(sh < 0)
  138.         d = d << shl;
  139.       else
  140.         d = d >> sh;
  141.        
  142.       matrix[y] = d;
  143.     }
  144.  
  145.     for(int y = 0; y < 8; y++)
  146.     {
  147.       mled.disBuffer[y] = matrix[y];
  148.     }
  149.    
  150.     mled.display();
  151.     delay(70);
  152.  
  153.     if(x % 5 == 0)
  154.     {
  155.       //-- zde by me nabehnout druhy znak
  156.     }
  157.      
  158.     sh--;
  159.     if(sh < 0)
  160.       shl++;
  161.    
  162.   }
  163.  
  164.   firstNum++;
  165.   if(firstNum > (sizeof(nums) / 8) - 1 )
  166.     firstNum = 0;
  167.  
  168. }
  169.  
  170. void charByte(int nChar)
  171. {
  172.   int x = 0;
  173.   for(int y = (nChar * 8); y < (nChar * 8) + 8; y++)
  174.   {  
  175.     workbyte[x] = nums[y];
  176.     x++;
  177.   }
  178. }
  179.  
Advertisement
Add Comment
Please, Sign In to add comment