Thanks Rai!
What is happening with the code you have? Does it do anything at all?
I see a few potential issues to begin with.
The way your function works right now, it only bounces one strip and once completed it bounces the second one.
Is this what you want? Or do they need to run in parallel?
The first problem is that you use the "setAll" and "showStrip" without having it modified to work for both strips.
Right now you have:
void setAll(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}
I would probably modify it to something like the following.
I would rewrite "showStrip()" to (I removed the FastLED code as well):
void showStrip(byte stripnumber) {
if (stripnumber==1) {
strip.show(); }
else {
strip_2.show(); }
}
Which implies that every call for "showStrip" has to be changed to "showStrip(1)" for strip 1 and "showStrip(2)" for strip 2.
Next I'd modify the "setAll()" function to something like this:
void setAll(byte red, byte green, byte blue, byte stripnumber) {
int number_of_leds;
if(stripnumber==1) {
number_of_leds=NUM_LEDS; }
else {
number_of_leds=NUM_LEDS_B; }
for(int i = 0; i < number_of_leds; i++ ) {
setPixel(i, red, green, blue);
}
showStrip(stripnumber);
}
Which means that all calls for "setAll()" need to be changed to "setAll(1)" for strip 1 or "setAll(2)" for strip 2.
Of course you can now clean up "setPixel()" as well, to the following since you use NeoPixel anyway:
void setPixel(int Pixel, byte red, byte green, byte blue) {
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
strip_2.setPixelColor(Pixel, strip_2.Color(red, green, blue));
}
But ... I'd change it even to add the stripnumber as well, to something like this:
void setPixel(int Pixel, byte red, byte green, byte blue, byte stripnumber) {
if(stripnumber==1) {
strip.setPixelColor(Pixel, strip.Color(red, green, blue)); }
else {
strip_2.setPixelColor(Pixel, strip_2.Color(red, green, blue)); }
}
Again, you need to modify all calls for "setPixel" as well, so "setAll" for example would become:
void setAll(byte red, byte green, byte blue, byte stripnumber) {
int number_of_leds;
if(stripnumber==1) {
number_of_leds=NUM_LEDS; }
else {
number_of_leds=NUM_LEDS_B; }
for(int i = 0; i < number_of_leds; i++ ) {
setPixel(i, red, green, blue, stripnumber);
}
showStrip(stripnumber);
}
Based on these suggested changes, your code would look something like this:
#include <Adafruit_NeoPixel.h>
#define NUM_LEDS 60
#define NUM_LEDS_B 10
#define PIN 10
#define PIN_B 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip_2 = Adafruit_NeoPixel(NUM_LEDS_B, PIN_B, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip_2.begin();
strip.show();
strip_2.show();
// Initialize all pixels to 'off'
}
void loop() {
CylonBounce(255, 255, 255, 10, 10, 50);
}
void CylonBounce(byte red, byte green, byte blue, int EyeSize, int SpeedDelay, int ReturnDelay){
for(int i = 0; i < NUM_LEDS-EyeSize-2; i++){
setAll(0,0,255,1); // added strip number
setPixel(i, red/10, green/10, blue/10,1); // added strip number
for(int j = 1; j <= EyeSize; j++) {
setPixel(i+j, red, green, blue,1); // added strip number
}
setPixel(i+EyeSize+1, red/10, green/10, blue/10,1); // added strip number
showStrip(1); // added strip number
delay(SpeedDelay);
}
delay(ReturnDelay);
for(int i = NUM_LEDS-EyeSize-2; i > 0; i--) { // added stripnumbers here too
setAll(0,0,255,2);
setPixel(i, red/10, green/10, blue/10,2);
for(int j = 1; j <= EyeSize; j++) {
setPixel(i+j, red, green, blue,2);
}
setPixel(i+EyeSize+1, red/10, green/10, blue/10,2);
showStrip(2);
delay(SpeedDelay);
}
delay(ReturnDelay);
}
// REPLACE TO HERE
void showStrip(byte stripnumber) {
if (stripnumber==1) {
strip.show(); }
else {
strip_2.show(); }
}
void setPixel(int Pixel, byte red, byte green, byte blue, byte stripnumber) {
if(stripnumber==1) {
strip.setPixelColor(Pixel, strip.Color(red, green, blue)); }
else {
strip_2.setPixelColor(Pixel, strip_2.Color(red, green, blue)); }
}
void setAll(byte red, byte green, byte blue, byte stripnumber) {
int number_of_leds;
if(stripnumber==1) {
number_of_leds=NUM_LEDS; }
else {
number_of_leds=NUM_LEDS_B; }
for(int i = 0; i < number_of_leds; i++ ) {
setPixel(i, red, green, blue, stripnumber);
}
showStrip(stripnumber);
}
Now mind you that I've only adapted the few functions to work with 2 strips instead of one.
Your loop to do the bounce, is probably in need of some change as well - depending on the effect you'd like.
Please review the code, I did type this without testing ...