Speed up rgb led strip rainbow wave

Hey guys!

I'm trying to figure out how to speed up the movement of this rainbow wave i use with neopixel.

if i register 10 LED's, the wave moves fast, if i register 50 LED's it moves very slow.

Does someone know which Variable i have to change or what to do?

Thank in advance

Regards
DarioCas

#include <Adafruit_NeoPixel.h>

// constants won't change. They're used here to 
// set pin numbers:
const int ledPin = 2;     // the number of the neopixel strip
const int numLeds = 50;
const int speed = 10;

//Adafruit_NeoPixel pixels = Adafruit_NeoPixel(8, ledPin);
Adafruit_NeoPixel strip = Adafruit_NeoPixel(numLeds, ledPin, NEO_GRB + NEO_KHZ800);


void setup() {
  strip.begin();

}

void loop() {

    
    rainbow(0);
    

}


void rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i*3+j) & 255));
    }
    strip.show();
  }
}


// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
    return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } 
  else if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } 
  else {
    WheelPos -= 170;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}

I don't think you can speed it up. There are no delay() in your code, it is going as fast as it can. Longer strips take longer to update.

But it must be updating hundreds of times per second. Faster than the eye can see. There is no point updating the strip more than, say, 50 times per second.

I think your perception of different speeds must be due to the speed at which the rainbow pattern is cycling.

You can increase the cycle speed like this:

 for(j=0; j<256; j+=2) {

Change the 2 for higher numbers to increase the cycle speed.

Also you can change the length of the rainbow by changing the value 3 in this line:

strip.setPixelColor(i, Wheel((i*3+j) & 255));

PaulRB:
I don't think you can speed it up. There are no delay() in your code, it is going as fast as it can. Longer strips take longer to update.

But it must be updating hundreds of times per second. Faster than the eye can see. There is no point updating the strip more than, say, 50 times per second.

I think your perception of different speeds must be due to the speed at which the rainbow pattern is cycling.

You can increase the cycle speed like this:

 for(j=0; j<256; j+=2) {

Change the 2 for higher numbers to increase the cycle speed.

Also you can change the length of the rainbow by changing the value 3 in this line:

strip.setPixelColor(i, Wheel((i*3+j) & 255));

Hi PaulRB!

Thanks for your help, i appreciate it!

Regards