Go Down

Topic: A Christmas Project: FastLED or crappy coding (me (most likely me))...  (Read 726 times) previous topic - next topic


I've got a new outside light project (namely 500leds outside the house ready for Christmas). All tested and working (for now). To date the 5 strips have been  run at 1/5 brightness for about 30mins at 2:30am so no one saw them  :smiley-cool: )

I've been trying to write a sequence (using FastLED) so they flash Red/Green alternately for a few seconds before seeming to fizzle out then try to make it look like a fuse is lit before I get the main sequence (built around the DemoReel sequence) starts up with all the colours of the rainbow (and hopefully blows away the neighbors efforts).

But I just cant figure out why it doesn't work. I'm ok with the practical bits (fitting the leds, and superstructure) but the coding side is blowing my mind ATM so please excuse the crappy coding that follows...

The code is set to 75 leds so I can test it with the plan to upscale it once its working. I added a few serial.print commands to see if I could follow where it fails... but alas no. In fact it seems to produce garbage on the display or just reports a few letters before seeming to crash.  :'(

I've been looking at this for about a week now and have tried to pull it apart and rebuid SO MANY TIMES that my kids have learnt a few words that my wife isn't impressed about.  ;)

I'm 100% sure its something I've overlooked or just got plain wrong but I'm at my wits end with this. Also forgive me for just cut and pasting here:-

#include "FastLED.h"

#define NUM_LEDS 75
#define PIN 3
#define Brightness 40

// strip lengths TEST STRIP is only 75leds long
// remarks are for future addition to existing 499 led strip
#define S1   10   //66
#define S2   15   //142
#define S3   15   //71
#define S4   5    //91
#define S5   25   //128

int RunOnce = true ;
void setup()
  FastLED.addLeds<WS2812B, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );

void loop() {
  if (RunOnce == true ){
    RunOnce = false ;
// rgb(1st colour), delay, rgb (2nd Colour), how many times (3000x3)
    SolidFill( 255 , 0, 0, 3000, 0, 255, 0 , 3 );
    Serial.println("SolidFill Complete...");
// Fizzle (red, green, blue), count, speed delay, only one twinkle (true/false)
    Fizzle(0xff, 0xff, 0xff, 300, 1, true);
    Serial.println("Fizzle Complete...");
//    Fuse(); //fade in Fuse
//    FastLED.setBrightness(Brightness);
//  Move MeteorRain to below fuse in real life
//  meteorRain - Color (red, green, blue), meteor size, trail decay, random trail decay (true/false), speed delay
     MeteorRain(0xff,0xff,0xff,2, 200, true, 50);
     Serial.println("MeteorRain Complete...");   

void SolidFill (int r, int g, int b, int Wait, int r1, int g1, int b1, int Times){
Serial.println("Start SolidFill...");
// do
// Plan to remove the "x" loop as I feel the do-until commnd would be better (if I get the theory right)
// but this isnt my issue for now...
for (int x = 0 ; x <= 10 ; x++){
  if (Wait >=2)
   for ( int i = 0 ; i <= Times; i++){
    fill_solid (leds, S1, CRGB( r, g, b));
    fill_solid (leds+S1, S2, CRGB( r1, g1, b1));
    fill_solid (leds+(S1+S2), S3, CRGB( r, g,b));
    fill_solid (leds+(S1+S2+S3), S4, CRGB( r1, g1, b1));
    fill_solid (leds+(S1+S2+S3+S4), NUM_LEDS, CRGB( r, g, b));
    delay (Wait);
    fill_solid (leds, S1, CRGB( r1, g1, b1));
    fill_solid (leds+S1, S2, CRGB( r, g, b));
    fill_solid (leds+(S1+S2), S3, CRGB( r1, g1, b1));
    fill_solid (leds+(S1+S2+S3), S4, CRGB( r, g, b));
    fill_solid (leds+(S1+S2+S3+S4), NUM_LEDS, CRGB( r1, g1, b1));
    delay (Wait);
 if (Wait <=1000)
Wait = Wait/2;
  Wait = Wait - 1000;
// } while ( Wait >=2);

void MeteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) { 
//  setAll(0,0,0);
  Serial.println("MeteorRain Started...");
  for(int i = 0; i < NUM_LEDS+NUM_LEDS; i++) {
    // fade brightness all LEDs one step
    for(int j=0; j<NUM_LEDS; j++) {
      if( (!meteorRandomDecay) || (random(10)>5) ) {
        fadeToBlack(j, meteorTrailDecay );       
    // draw meteor
    for(int j = 0; j < meteorSize; j++) {
      if( ( i-j <NUM_LEDS) && (i-j>=0) ) {
        setPixel(i-j, red, green, blue);

// used by meteorrain
void fadeToBlack(int ledNo, byte fadeValue) {
   leds[ledNo].fadeToBlackBy( fadeValue );

void Fizzle(byte red, byte green, byte blue, int Count, int SpeedDelay, boolean OnlyOne) {
  for (int i=0; i<Count; i++) {
     if(OnlyOne) {

void showStrip() {

void setPixel(int Pixel, byte red, byte green, byte blue) {
   leds[Pixel].r = red;
   leds[Pixel].g = green;
   leds[Pixel].b = blue;

void setAll(byte red, byte green, byte blue) {
  for(int i = 0; i < NUM_LEDS; i++ ) {
    setPixel(i, red, green, blue);

Any help would be brilliant at this stage.

Many thanks


Please read forum guide in the sticky post, so you know how to post code correctly and other important stuff. Then modify your post above and fix it, plus also please Auto-Format the code so we can see where the corresponding } to each { is.

Your Serial.print() are not working because there is no Serial.begin() in your setup().


Q1 : what type of LEDs are they and how are they wired and powered ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Go Up