Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- #define LED_PIN 6
- #define NUM_LEDS 256
- CRGB leds[NUM_LEDS];
- //prototype
- void displayNumber(); //declaration de la methode d'affichage de la matrice
- //variable globale
- // 0 = noir, 1 = rouge
- int digits[32][8] = {
- {1,1,1,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0},
- {0,0,0,0,0,0,0,0}
- };
- void setup() {
- FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
- }
- void loop() {
- // Définir les couleurs pour chaque LED de la matrice
- displayNumber(); //affiche les nombres dans la matrice
- // Envoyer les couleurs à la matrice
- FastLED.show();
- // Attendre pendant une seconde avant de passer au chiffre suivant
- delay(1000);
- }
- void displayNumber() {
- // 0 = noir, 1 = rouge
- // Afficher le chiffre sur la matrice
- for(int col = 0 ; col <32 ;col++){
- for(int row = 0 ; row <8 ;row++){
- int ledIndex = col*8 + row;
- if ( digits[col][row] ) leds[ledIndex] = CRGB::Red;
- else leds[ledIndex] = CRGB::Black;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment