granteeric

matrix123 modifier

Apr 25th, 2023
1,126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <FastLED.h>
  2.  
  3. #define LED_PIN 6
  4. #define NUM_LEDS 256
  5.  
  6. CRGB leds[NUM_LEDS];
  7.  
  8. //prototype
  9. void displayNumber();  //declaration de la methode d'affichage de la matrice
  10.  
  11. //variable globale
  12. // 0 = noir, 1 = rouge
  13.   int digits[32][8] = {
  14.     {1,1,1,0,0,0,0,0},
  15.     {0,0,0,0,0,0,0,0},
  16.     {0,0,0,0,0,0,0,0},
  17.     {0,0,0,0,0,0,0,0},
  18.     {0,0,0,0,0,0,0,0},
  19.     {0,0,0,0,0,0,0,0},
  20.     {0,0,0,0,0,0,0,0},
  21.     {0,0,0,0,0,0,0,0},
  22.     {0,0,0,0,0,0,0,0},
  23.     {0,0,0,0,0,0,0,0},
  24.     {0,0,0,0,0,0,0,0},
  25.     {0,0,0,0,0,0,0,0},
  26.     {0,0,0,0,0,0,0,0},
  27.     {0,0,0,0,0,0,0,0},
  28.     {0,0,0,0,0,0,0,0},
  29.     {0,0,0,0,0,0,0,0},
  30.     {0,0,0,0,0,0,0,0},
  31.     {0,0,0,0,0,0,0,0},
  32.     {0,0,0,0,0,0,0,0},
  33.     {0,0,0,0,0,0,0,0},
  34.     {0,0,0,0,0,0,0,0},
  35.     {0,0,0,0,0,0,0,0},
  36.     {0,0,0,0,0,0,0,0},
  37.     {0,0,0,0,0,0,0,0},
  38.     {0,0,0,0,0,0,0,0},
  39.     {0,0,0,0,0,0,0,0},
  40.     {0,0,0,0,0,0,0,0},
  41.     {0,0,0,0,0,0,0,0},
  42.     {0,0,0,0,0,0,0,0},
  43.     {0,0,0,0,0,0,0,0},
  44.     {0,0,0,0,0,0,0,0},
  45.     {0,0,0,0,0,0,0,0}
  46.   };
  47.  
  48.  
  49.  
  50. void setup() {
  51.   FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
  52. }
  53.  
  54.  
  55. void loop() {
  56.   // Définir les couleurs pour chaque LED de la matrice
  57.   displayNumber();  //affiche les nombres dans la matrice
  58.  
  59.     // Envoyer les couleurs à la matrice  
  60.     FastLED.show();
  61.  
  62.     // Attendre pendant une seconde avant de passer au chiffre suivant
  63.     delay(1000);
  64. }
  65.  
  66. void displayNumber() {
  67.   // 0 = noir, 1 = rouge
  68.   // Afficher le chiffre sur la matrice
  69.   for(int col = 0 ; col <32 ;col++){
  70.     for(int row = 0 ; row <8 ;row++){
  71.         int ledIndex = col*8 + row;
  72.         if ( digits[col][row] ) leds[ledIndex] = CRGB::Red;
  73.         else leds[ledIndex] = CRGB::Black;
  74.     }
  75.   }
  76. }
  77.  
Advertisement
Add Comment
Please, Sign In to add comment