Bonjour à vous la communauté.
Je me permets de vous adresser ce petit sujet car j'ai un soucis de lenteur sur mon projet.
Voila j'ai acquis 3 bandeaux de LED de type WS2812B ( 900 leds en tout )relié en série avec ajout de puissance sur chacun des bandeaux mais contrôlés avec une seule sortie.
J'ai un arduino ATMega 2560 avec une alimentation 5V 10A.
Mon programme s'effectue correctement mais lorsque je souhaite faire des effets de vague ou autre (voir mon programme ) cela s'effectue très lentement.
Auriez-vous une ptite idée ?
Hello to you community.
I take the liberty of addressing this little subject to you because I have a problem with the slowness of my project.
Here I have acquired 3 LED strips of the WS2812B type (900 LEDs in all) connected in series with addition of power on each strip but controlled with a single output.
I have an arduino ATMega 2560 with a 5V 10A power supply.
My program is done correctly but when I want to do wave effects or other (see my program) it is done very slowly.
Do you have any idea?
#include <FastLED.h>
#define DATA_PIN 6
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS 844
#define BRIGHTNESS 200
#define FRAMES_PER_SECOND 220
CRGB leds[NUM_LEDS];
CRGBPalette16 paletterouge = CRGBPalette16 (
CRGB::Red,
CRGB::Red,
CRGB::Red,
CRGB::Red,
CRGB::GhostWhite ,
CRGB::GhostWhite ,
CRGB::Red,
CRGB::GhostWhite ,
CRGB::GhostWhite ,
CRGB::GhostWhite ,
CRGB::Red,
CRGB::Red,
CRGB::Red,
CRGB::Red,
CRGB::GhostWhite ,
CRGB::Red
);
CRGBPalette16 palettebleue = CRGBPalette16 (
CRGB::Blue,
CRGB::Blue,
CRGB::Blue,
CRGB::Blue,
CRGB::White,
CRGB::White,
CRGB::Blue,
CRGB::White,
CRGB::White,
CRGB::White,
CRGB::Blue,
CRGB::Blue,
CRGB::Blue,
CRGB::Blue,
CRGB::White,
CRGB::Blue
);
uint16_t hue = 0;
uint16_t paletteIndex = 0;
uint16_t colorIndex[NUM_LEDS];
void setup() {
fill_solid(leds,NUM_LEDS,CRGB (0,0, 0));
delay(5000); // 3 second delay for recovery
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
}
typedef void (*SimplePatternList[])();
SimplePatternList gPatterns = {Vague_Bleue_Blanc,Scintillement,Vague_Rouge_Vert,Scintillement,Defilement,Scintillement,bpm,Scintillement,juggle,Scintillement,sinelon};
uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t gHue = 0;
void loop() {
gPatterns[gCurrentPatternNumber]();
FastLED.show();
//FastLED.delay(1000/FRAMES_PER_SECOND);
EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow
EVERY_N_SECONDS( 120 ) { nextPattern(); } // change patterns periodically
}
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
void nextPattern()
{
// add one to the current pattern number, and wrap around at the end
gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
}
////////////////////////////////////////////////////////////////////////////////////
void juggle() {
// eight colored dots, weaving in and out of sync with each other
fadeToBlackBy( leds, NUM_LEDS, 20);
byte dothue = 0;
for( int i = 0; i < 8; i++) {
leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(random8(200,255), 200, 255);
dothue += 32;
}
}
void bpm()
{
// colored stripes pulsing at a defined Beats-Per-Minute (BPM)
uint8_t BeatsPerMinute = 62;
CRGBPalette16 palette = paletterouge;
uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
for( int i = 0; i < NUM_LEDS; i++) { //9948
leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
}
}
void sinelon()
{
// a colored dot sweeping back and forth, with fading trails
fadeToBlackBy( leds, NUM_LEDS, 20);
int pos = beatsin16( 23, 0, NUM_LEDS-1 );
leds[pos] += CHSV( random8(200,255), 255, 192);
}
void Scintillement() {
// FastLED.setBrightness (255);
FastLED.show();
leds[random(0,NUM_LEDS)]=CRGB::White;
leds[random(0,NUM_LEDS)]=CRGB::Blue;
FastLED.show();
fill_solid(leds,NUM_LEDS,CRGB (0,0, 0));
// delay(1);
}
void Defilement() {
// EVERY_N_MILLISECONDS(1) {
// Create a new HSV color for led[0]
leds[0] = CHSV(0, random8(), random8(100, 255));
for (int i = NUM_LEDS - 1; i > 0; i--) {
leds[i] = leds[i - 1];
}
FastLED.show();
//}
}
void Vague_Rouge_Vert () {
uint16_t sinBeat = beatsin16(30, 0, NUM_LEDS - 1, 0, 0);
uint16_t sinBeat2 = beatsin16(30, 0, NUM_LEDS - 1, 0, 21845);
uint16_t sinBeat3 = beatsin16(30, 0, NUM_LEDS - 1, 0, 43690);
uint16_t sinBeat4 = beatsin16(30, 0, NUM_LEDS - 1, 0, 31845);
leds[sinBeat] = CRGB::Red;
leds[sinBeat2] = CRGB::Green;
leds[sinBeat3] = CRGB::Red;
leds[sinBeat4] = CRGB::Green;
fadeToBlackBy(leds, NUM_LEDS, 10);
FastLED.show();
}
void Vague_Bleue_Blanc() { //defilment couleur palette
fill_palette (leds, NUM_LEDS, paletteIndex, 255 / 100, palettebleue, 255 , LINEARBLEND);
// EVERY_N_MILLISECONDS(1){
paletteIndex++;
// }
FastLED.show();
}