I tried controlling an rgb ws2812b led strip with my pi 3. That works fine. Now I wanted to do it with my Arduino Nano. The control itself works. If I put some code into the loop function everything works fine. But if I want to call the code by a function, say void colorWipe(){ change color } and I call colorWipe() in the loop, it doesn't change color anymore. WHY???
Here is the code:
#include <Adafruit_NeoPixel.h>
#define shortStrip 2
#define longStrip 3
#define led_count_short 23
#define led_count_long 277
Adafruit_NeoPixel strip_short = Adafruit_NeoPixel(led_count_short, shortStrip, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip_long = Adafruit_NeoPixel(led_count_long, longStrip, NEO_GRB + NEO_KHZ800);
void setup(){
Serial.begin(9600);
strip_short.begin();
strip_short.setBrightness(50);
strip_short.show();
Serial.println("Short strip is running!");
delay(50);
strip_long.begin();
strip_long.setBrightness(50);
strip_long.show();
Serial.println("Long strip is running!");
delay(50);
}
void loop(){
colorWipe(10, strip_long, led_count_long, 255, 255, 255);
Serial.println("Finished Long");
delay(1000);
colorWipe(10, strip_long, led_count_long, 255, 0, 0);
Serial.println("This too Long");
delay(1000);
}
void colorWipe(uint8_t wait, Adafruit_NeoPixel strip, int led_count, int r, int g, int b){
Serial.print("1");
for(int i = 0; i < led_count; i++){
strip.setPixelColor(i, strip.Color(r,g,b));
strip.show();
delay(wait);
}
Serial.print("2");
return;
}
Yes I do have 2 led strips, but only 1 is called in the loop. My serial monitor is printing everything perfectly fine, but the colors just don't change. I've tried multiple colors. The first colorWipe() works, all colorwipes after do not.
PLS HELP
Thank you very much