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.