Combining two sketches Flora

Hello, I have been trying to combine these two sketches for a flora to program a neopixel LED strip:
#include <Adafruit_NeoPixel.h>

#define PIN 6
#define PIXEL 6

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}


void loop() {
  int R = 0;
  int G = 0;
  int B = 0;
  //Fade in
  for(R && G && B; R<126 && G<126 && B<126; R++ && G++ && B++) {
    for(int i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, strip.Color(R, G, B));
      strip.show();
      delay(0);
    }
    delay(3);
  }
  //Fade Out
  for(R && G && B; R>-1 && G>-1 && B>-1; R-- && G-- && B--) {
    for(int j=0; j<strip.numPixels(); j++) {
      strip.setPixelColor(j, strip.Color(R, G, B));
      strip.show();
      delay(0);
    }
    delay(3);
  }
}

and

#include <Adafruit_NeoPixel.h>

#define PIN      6
#define N_LEDS 144

Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
}

void loop() {
  chase(strip.Color(255, 0, 0)); // Red
  chase(strip.Color(0, 255, 0)); // Green
  chase(strip.Color(0, 0, 255)); // Blue
}

static void chase(uint32_t c) {
  for(uint16_t i=0; i<strip.numPixels()+4; i++) {
      strip.setPixelColor(i  , c); // Draw new pixel
      strip.setPixelColor(i-4, 0); // Erase pixel a few steps back
      strip.show();
      delay(25);
  }
}

This is the combined code that I made:

#include <Adafruit_NeoPixel.h>

#define PIN 6
#define N_LEDS 6

Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}


void loop() {
  int R = 0;
  int G = 0;
  int B = 0;
  //Fade in
  for(R && G && B; R<126 && G<126 && B<126; R++ && G++ && B++) {
    for ( int i = 0; i < 5 ; i++) {
      strip.setPixelColor(i, strip.Color(R, G, B));
      strip.show();
      delay(0);
    }
    delay(3);
  }
  //Fade Out
  for(R && G && B; R>-1 && G>-1 && B>-1; R-- && G-- && B--) {
    for(int j=0; j<strip.numPixels(); j++) {
      strip.setPixelColor(j, strip.Color(R, G, B));
      strip.show();
      delay(0);
    }
    delay(3);
  }
    
    {strip.begin();}
  {chase(strip.Color(255, 0, 0)); // Red
  chase(strip.Color(0, 255, 0)); // Green
  chase(strip.Color(0, 0, 255)); // Blue
}
  
{static void chase(uint32_t c) 
  for(uint16_t i=0; i<strip.numPixels()+4; i++) {
      strip.setPixelColor(i  , c); // Draw new pixel
      strip.setPixelColor(i-4, 0); // Erase pixel a few steps back
      strip.show();
      delay(25);
  }
}}

However when I combined them, I shows an issue that the "chase" variable was not declared in the scope. I'm new to coding and need this for a school art project, so please be kind ^^; If anyone could provide me with a fixed code, I would greatly appreciate that as I'm not very versed in the lingo of Arduino.

That's an unusual place for a {

In fact, there's an over-abundance of { and }

What do I need to fix/delete?

Quite a lot, it seems

Could you perhaps provide something a bit more constructive in terms of advice? I copied both of these codes (one from the Adafruit website and the other from another forum). Both work perfectly fine on their own, I am just lost on how to combine them so that it still functions. Once again, I don’t know anything about Arduino coding, so I’m not really sure what’s wrong with any of the things you’re quoting in my code without explanations :frowning:

Can you see the difference between this

and this

?

Yes, I ended up moving the bracket after you pointed it out, but it still gave me the same error code.

Which you forgot to share.

I put in the forum that it says that the variable “chase” isn’t declared in the scope, im sorry if it wasn’t very clear :frowning: this is my first time on these forums

The forum provides sticky posts giving details of how best to use the forum.

I'd be really disappointed if Adafruit published that

Hello
I guess there a some other coding items to be clarified.

 warning: statement has no effect [-Wunused-value]

   for (R && G && B; R > -1 && G > -1 && B > -1; R-- && G-- && B--) {

        ~~~~~~~^~~~

I think these lines of code are pseudo code and have to be coded correctly.

Have a nice day and enjoy coding in C++.
Дайте миру шанс!

for (;

Would be simpler.

This is the code that I got from a forum, the other code is the Adafruit code; It's the only one that I could find for flora that would code a fading light without any issues.

How would I code it correctly?

Why did you add the { and the } when they were not present in the original code?

Hello beetlbrite
Take a view to gain the knowledge.
https://www.learncpp.com/cpp-tutorial/for-statements/
Specially the section "Omitted expressions"

Have a nice day and enjoy coding in C++.
Дайте миру шанс!

I believe I was experimenting with the placement of code to see if I could remedy the error message.

Post both original sketches you found and claim work perfectly.

a7

I think they'll work, but the non-Adafruit is just weird.