Bonjour ,
Je souhaiterais effectuer un Groupe d'actions dans ma Boucle , actuellement je passe un élément après l'autre mais je souhaiterais effectuer 3 actions identique sur 3 pin différents au même moment , avez bous une idée de comment écrire ce code ?
Merci d'avance
#include <FastLED.h>
#define NUM_LEDS1 31
#define NUM_LEDS2 31
#define NUM_LEDS3 28
#define NUM_LEDS4 38
#define NUM_LEDS5 170
#define NUM_LEDS6 25
#define NUM_LEDS7 24
#define DATA_PIN2 2
#define DATA_PIN3 3
#define DATA_PIN4 4
#define DATA_PIN5 5
#define DATA_PIN6 6
#define DATA_PIN7 7
#define DATA_PIN8 8
#define BRIGHTNESS 160 //luminosité entre 0 et 255.
CRGB leds1[NUM_LEDS1];
CRGB leds2[NUM_LEDS2];
CRGB leds3[NUM_LEDS3];
CRGB leds4[NUM_LEDS4];
CRGB leds5[NUM_LEDS5];
CRGB leds6[NUM_LEDS6];
CRGB leds7[NUM_LEDS7];
void setup() {
FastLED.addLeds<WS2812B, DATA_PIN2, GRB>(leds1, NUM_LEDS1).setCorrection(TypicalLEDStrip);
FastLED.addLeds<WS2812B, DATA_PIN3, GRB>(leds2, NUM_LEDS2).setCorrection(TypicalLEDStrip);
FastLED.addLeds<WS2812B, DATA_PIN4, GRB>(leds3, NUM_LEDS3).setCorrection(TypicalLEDStrip);
FastLED.addLeds<WS2812B, DATA_PIN5, BRG>(leds4, NUM_LEDS4).setCorrection(TypicalLEDStrip);
FastLED.addLeds<WS2812B, DATA_PIN6, GRB>(leds5, NUM_LEDS5).setCorrection(TypicalLEDStrip);
FastLED.addLeds<WS2812B, DATA_PIN7, BRG>(leds6, NUM_LEDS6).setCorrection(TypicalLEDStrip);
FastLED.addLeds<WS2812B, DATA_PIN8, BRG>(leds7, NUM_LEDS7).setCorrection(TypicalLEDStrip);
pinMode(DATA_PIN2, OUTPUT); // la broche led (2) est initialisée en sortie BRANCHE 1
pinMode(DATA_PIN3, OUTPUT); // la broche led (3) est initialisée en sortie BRANCHE 2
pinMode(DATA_PIN4, OUTPUT); // la broche led (4) est initialisée en sortie BRANCHE 3
pinMode(DATA_PIN5, OUTPUT); // la broche led (5) est initialisée en sortie BRANCHE 4
pinMode(DATA_PIN6, OUTPUT); // la broche led (6) est initialisée en sortie BRANCHE 5
pinMode(DATA_PIN7, OUTPUT); // la broche led (7) est initialisée en sortie BRANCHE 6
pinMode(DATA_PIN8, OUTPUT); // la broche led (8) est initialisée en sortie BRANCHE 7
FastLED.setBrightness(BRIGHTNESS);
digitalWrite(DATA_PIN2, LOW); // Eteindre PIN 2
digitalWrite(DATA_PIN3, LOW); // Eteindre PIN 3
digitalWrite(DATA_PIN4, LOW); // Eteindre PIN 4
digitalWrite(DATA_PIN5, LOW); // Eteindre PIN 5
digitalWrite(DATA_PIN6, LOW); // Eteindre PIN 6
digitalWrite(DATA_PIN7, LOW); // Eteindre PIN 7
digitalWrite(DATA_PIN8, LOW); // Eteindre PIN 8
}
void loop() {
//DEBUT ALLUMAGE
for (int i = 31; i >= 0; i--) {
leds1[i - 4] = CRGB::White;
FastLED.show();
delay(15);
leds1[i] = CRGB::Black;
FastLED.show();
}
for (int i = 31; i >= 0; i--) {
leds2[i - 4] = CRGB::White;
FastLED.show();
delay(15);
leds2[i] = CRGB::Black;
FastLED.show();
}
for (int i = 28; i >= 0; i--) {
leds3[i - 4] = CRGB::White;
FastLED.show();
delay(15);
leds3[i] = CRGB::Black;
FastLED.show();
}
for (int i = 38; i >= 0; i--) {
leds4[i - 4 ] = CRGB::White;
FastLED.show();
delay(15);
leds4[i] = CRGB::Black;
FastLED.show();
}
for (int i = 29; i >= 0; i--) {
leds5[i - 4 ] = CRGB::White;
FastLED.show();
delay(15);
leds5[i] = CRGB::Black;
FastLED.show();
}
for (int i = 25; i >= 0; i--) {
leds6[i - 4 ] = CRGB::White;
FastLED.show();
delay(15);
leds6[i] = CRGB::Black;
FastLED.show();
}
for (int i = 24; i >= 0; i--) {
leds7[i - 4 ] = CRGB::White;
FastLED.show();
delay(15);
leds7[i] = CRGB::Black;
FastLED.show();
}
}
