adafruit / Adafruit_NeoPixel

Arduino library for controlling single-wire LED pixels (NeoPixel, WS2812, etc.)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rainbow() hue variable does nothing

AnasMalas opened this issue · comments

  • Arduino board: Arduino Leonardo (16 MHz) compatible board, also checked online with an Arduino Mega simulator
  • Arduino IDE version: Arduino cloud editor, Web App Version 6.4.5

All inputs into the hue variable seem to be lost somewhere. The strip is always stuck with red as the very first color. The only variable that moves colors around is the number of rainbows per strip. Here are three tries:

#include <Adafruit_NeoPixel.h> //Used for the LED strips
Adafruit_NeoPixel returns(60, A1, NEO_GRBW + NEO_KHZ800);

void setup() {
  returns.begin();
  returns.show();
}

void loop() {
  static int count;
  returns.rainbow(count, 1, 255, 200, 1);
  returns.show();
  count++;
  delay(100);
}

which gets the same result as:

#include <Adafruit_NeoPixel.h> //Used for the LED strips
Adafruit_NeoPixel returns(60, A1, NEO_GRBW + NEO_KHZ800);

void setup() {
  returns.begin();
   returns.rainbow(0, 1, 255, 200, 1);
  returns.show();
}

void loop() { }

This does move the colors, but that's not exactly how I want it to go about this :)

#include <Adafruit_NeoPixel.h> //Used for the LED strips
Adafruit_NeoPixel returns(60, A1, NEO_GRBW + NEO_KHZ800);

void setup() {
  returns.begin();
  returns.show();
}

void loop() {
  static int count;
  returns.rainbow(0, count, 255, 200, 1);
  returns.show();
  count++;
  delay(100);
}

I found an online simulator and put code into them for your convenience:
changing first hue does nothing: https://wokwi.com/projects/344930901661057620
changing number of rainbows does something: https://wokwi.com/projects/344930973765337683
Setting number of rainbows to 0 and changing hue does nothing: https://wokwi.com/projects/344931036485911123

Reading through the .h and .cpp files, I think the way im using the function is logically sound. When I dry run the code I expect a flowing rainbow of neon glory, however I get a static rainbow of neon glory :(

Turns out I made the world's slowest animation. count++ needs a little less than 2 hours to cycle the whole strip. d'oh! But hey, lets not waste an issue. I think examples should be updated to use this function instead of defining a rainbow function in each one. I will close this issue