my first noob neo pixel ring project

hi Guys

it's been a long time that I've visited the arduino forum.

I'm a real noob in arduino language , to bad I don't speak it :slight_smile:

I am doing a project for my daughter . I have a old boring ceiling light and I integrated a neopixel ring with 24 leds.
I was very lucky that the excisting led ring was the same inner diameter as the neo pixel ring so I could attach the ring to this piece to keep it in place

I found the code here NeoPixel x Arduino x Button - Hackster.io

I already did add some colors and deleted parts of the code

But I am struggling a bit with the code . I want to adjust it , but as I 've mentioned before I'm a noob at programming .

Here is my problem

I have 5 solid colors in a row . Those work fine each time I push the button to change the color.

The 6 th an 7 th push of the button gives me the rainbow ,rainbowcycle and theaterChaseRainbow ( case 6 and 7 and 8 in the sketch ) but I want those be in a loop .

when I come to case 6 , I can't go to case 7 until the complete cycle has ended . The same if I want to go from case 7 to 8 I have to wait until the cyclus is ended .

so this is what I want :
I just want to get every rainbow effect in a loop and toggle all modes with the touch of a button without waiting ,so my daughter can choose what mood effect she wants . , and get everything rainbow effect in a loop .

I really hope someone can help me out , because it's kind of a x mass gift and I've been struggling all week long .

Stay save and happy holidays

Greetings from Belgium Bart

in attach my ceiling light code . I Also have another code ( rainbow loop ) i've found and I don't know if it is possible to integrate it in my code . It also has a nice effect . I will put it also as attach , so maybe someone can melt those 2 together for me

this is a short video of my project

https://drive.google.com/file/d/18LpYH4Bhq7iLBnTJF2-q1Yysc98BOOdo/view?usp=sharing

ceiling_light.ino (4.21 KB)

rainbow_loop.ino (2.34 KB)

ceiling_light_no_button.ino (4.72 KB)

faulty_file.ino (4.53 KB)

Here's a new version of your rainbow function:

void rainbow(uint8_t wait)
{
  uint16_t i, j;
  while (true)
  {
    for (j = 0; j < 256; j++)
    {
      for (i = 0; i < strip.numPixels(); i++)
      {
        strip.setPixelColor(i, Wheel((i + j) & 255));
        if(digitalRead(BUTTON_PIN)==LOW)
          return;
      }
      strip.show();
      delay(wait);
    }
  }
}

It loops continuously until the button is pressed. You might need to add a delay at the start of the function to give your daughter a chance to get her finger off the button.

Obviously, you can use the same pattern for the other two rainbow functions.

Compiled, not tested.

hi thx for the response

if I change the code with yours , it still does not loop the rainbow

Did you change it manually or copy & paste?

copy paste

So what does it actually do now?

it does exactly the same , after each sequence the cycle stops on full colour.

when I press the button it spins the lights around , but after the cycle all the lights stand still.

i hope I did everythin right . I just copy past you're code to replace that exactly code of the original ?

That's it, just replace the original Rainbow function with the new.

Try putting a delay before the while loop so you have time to release the button.

i tried this and it works , but all the loops run in 1 sequence .
I even don't have to push a button .

Maybe it's easier to add a command for the button ?

But how do I do that ?

uploaded the file

Same thing again I expect. Try this:

void rainbow(uint8_t wait)
{
  uint16_t i, j;
  delay(1000);
  while (true)
  {
    for (j = 0; j < 256; j++)
    {
      for (i = 0; i < strip.numPixels(); i++)
      {
        strip.setPixelColor(i, Wheel((i + j) & 255));
        if(digitalRead(BUTTON_PIN)==LOW)
          {
          delay(1000);
          return;
          }
      }
      strip.show();
      delay(wait);
    }
  }
}

i get this error

'rainbow' was not declared in this scope

rainbow(20);

Sorry to take all you're time

Maybe this project is to big for me .

Post the code that produced that error.

You need to go and read the forum instructions so that you can go back and modify your original post (not re-post it) - using the "More -> Modify" option below the right hand corner of your post - to mark up your code as such using the "</>" icon in the posting window. Just highlight each section of code (or output if you later need to post that) from the IDE and click the icon.

In fact, the IDE itself has a "copy for forum" link to put these markings on a highlighted block for you so you then just paste it here in a posting window. But even before doing that, don't forget to use the "Auto-Format" (Ctrl-T) option first to make it easy to read. While you were lucky so far, If you do not post it as "code" it can easily be quite garbled and is always more difficult to read due to the font.

It is inappropriate to attach it as a ".ino" file unless it is clearly too long to include in the post proper. People can usually see the mistakes directly and do not want to have to actually load it in their own IDE. And even that would also assume they are using a PC and have the IDE running on that PC.

Also tidy up your blank space. Do use blank lines, but only single blanks between complete functional blocks.

Why do we think this is so important? Because it is really difficult to write code properly - as with any other task requiring care - if everything is disorganised!

thank you for the advice .
i will try to do my best .
I'm not used to put messages on forums . So I do apologize

#include <Adafruit_NeoPixel.h>

#define BUTTON_PIN   2    // Digital IO pin connected to the button.  This will be
// driven with a pull-up resistor so the switch should
// pull the pin to ground momentarily.  On a high -> low
// transition the button press logic will execute.

#define PIXEL_PIN    6   // Digital IO pin connected to the NeoPixels.

#define PIXEL_COUNT 24   // number of neopixel (change this accordingly)

// Parameter 1 = number of pixels in strip,  neopixel stick has 8
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_RGB     Pixels are wired for RGB bitstream
//   NEO_GRB     Pixels are wired for GRB bitstream, correct for neopixel stick
//   NEO_KHZ400  400 KHz bitstream (e.g. FLORA pixels)
//   NEO_KHZ800  800 KHz bitstream (e.g. High Density LED strip), correct for neopixel stick
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);

bool oldState = HIGH;
int showType = 0;

void setup() {
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  strip.begin();
  strip.setBrightness(100);  // Lower brightness and save eyeballs!
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {

  // Some example procedures showing how to display to the pixels:
  colorWipe(strip.Color(0, 0, 0), 50);    // Black
  colorWipe(strip.Color(255, 255, 255), 50);  // White
  colorWipe(strip.Color(0, 100, 0), 50);  // Green
  colorWipe(strip.Color(255, 165, 0), 50);  // Orange
  colorWipe(strip.Color(255, 0, 0), 50); // Red
  colorWipe(strip.Color(0, 0, 255), 50); // Blue
  rainbow(20);
  rainbowCycle(20);
  theaterChaseRainbow(50);

  // Get current button state.
  bool newState = digitalRead(BUTTON_PIN);

  // Check if state changed from high to low (button press).
  if (newState == LOW && oldState == HIGH) {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState = digitalRead(BUTTON_PIN);
    if (newState == LOW) {
      showType++;
      if (showType > 9)
        showType = 0;
      startShow(showType);
    }
  }

  // Set the last button state to the old state.
  oldState = newState;
}

void startShow(int i) {
  switch (i) {
    case 0: colorWipe(strip.Color(0, 0, 0), 50);    // Black/off
      break;
    case 1: colorWipe(strip.Color(255, 255, 255), 50);  // White
      break;
    case 2: colorWipe(strip.Color(0, 100, 0), 50);  // Green
      break;
    case 3: colorWipe(strip.Color(255, 165, 0), 50);  // Orange
      break;
    case 4: colorWipe(strip.Color(255, 0, 0), 50); // Red
      break;
    case 5: colorWipe(strip.Color(0, 0, 255), 50); // Blue
      break;
    case 6: rainbow(20);
      break;
    case 7: rainbowCycle(20);
      break;
    case 8: theaterChaseRainbow(50);
      break;
  }
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for (uint16_t i = 0; i < strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

theaterChaseRainbow(50);

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
    for (i = 0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
  for (int j = 0; j < 256; j++) {   // cycle all 256 colors in the wheel
    for (int q = 0; q < 3; q++) {
      for (int i = 0; i < strip.numPixels(); i = i + 3) {
        strip.setPixelColor(i + q, Wheel( (i + j) % 255)); //turn every third pixel on
      }
      strip.show();

      delay(wait);

      for (int i = 0; i < strip.numPixels(); i = i + 3) {
        strip.setPixelColor(i + q, 0);      //turn every third pixel off
      }
    }
  }
}

// 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);
  }
}

Here's a version that compiles:

#include <Adafruit_NeoPixel.h>

#define BUTTON_PIN   2    // Digital IO pin connected to the button.  This will be
// driven with a pull-up resistor so the switch should
// pull the pin to ground momentarily.  On a high -> low
// transition the button press logic will execute.

#define PIXEL_PIN    6   // Digital IO pin connected to the NeoPixels.

#define PIXEL_COUNT 24   // number of neopixel (change this accordingly)

// Parameter 1 = number of pixels in strip,  neopixel stick has 8
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_RGB     Pixels are wired for RGB bitstream
//   NEO_GRB     Pixels are wired for GRB bitstream, correct for neopixel stick
//   NEO_KHZ400  400 KHz bitstream (e.g. FLORA pixels)
//   NEO_KHZ800  800 KHz bitstream (e.g. High Density LED strip), correct for neopixel stick
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);

bool oldState = HIGH;
int showType = 0;

void setup()
{
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  strip.begin();
  strip.setBrightness(100);  // Lower brightness and save eyeballs!
  strip.show(); // Initialize all pixels to 'off'
}

void loop()
{
  // Some example procedures showing how to display to the pixels:
  colorWipe(strip.Color(0, 0, 0), 50);    // Black
  colorWipe(strip.Color(255, 255, 255), 50);  // White
  colorWipe(strip.Color(0, 100, 0), 50);  // Green
  colorWipe(strip.Color(255, 165, 0), 50);  // Orange
  colorWipe(strip.Color(255, 0, 0), 50); // Red
  colorWipe(strip.Color(0, 0, 255), 50); // Blue
  rainbow(20);
  rainbowCycle(20);
  theaterChaseRainbow(50);
  // Get current button state.
  bool newState = digitalRead(BUTTON_PIN);
  // Check if state changed from high to low (button press).
  if (newState == LOW && oldState == HIGH)
  {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState = digitalRead(BUTTON_PIN);
    if (newState == LOW)
    {
      showType++;
      if (showType > 9)
        showType = 0;
      startShow(showType);
    }
  }
  // Set the last button state to the old state.
  oldState = newState;
}

void startShow(int i)
{
  switch (i)
  {
    case 0: colorWipe(strip.Color(0, 0, 0), 50);    // Black/off
      break;
    case 1: colorWipe(strip.Color(255, 255, 255), 50);  // White
      break;
    case 2: colorWipe(strip.Color(0, 100, 0), 50);  // Green
      break;
    case 3: colorWipe(strip.Color(255, 165, 0), 50);  // Orange
      break;
    case 4: colorWipe(strip.Color(255, 0, 0), 50); // Red
      break;
    case 5: colorWipe(strip.Color(0, 0, 255), 50); // Blue
      break;
    case 6: rainbow(20);
      break;
    case 7: rainbowCycle(20);
      break;
    case 8: theaterChaseRainbow(50);
      break;
  }
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait)
{
  for (uint16_t i = 0; i < strip.numPixels(); i++)
  {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

void rainbow(uint8_t wait)
{
  uint16_t i, j;
  delay(1000);
  while (true)
  {
    for (j = 0; j < 256; j++)
    {
      for (i = 0; i < strip.numPixels(); i++)
      {
        strip.setPixelColor(i, Wheel((i + j) & 255));
        if(digitalRead(BUTTON_PIN)==LOW)
          {
          delay(1000);
          return;
          }
      }
      strip.show();
      delay(1000);
    }
  }
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait)
{
  uint16_t i, j;
  for (j = 0; j < 256 * 5; j++)   // 5 cycles of all colors on wheel
  {
    for (i = 0; i < strip.numPixels(); i++)
    {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait)
{
  for (int j = 0; j < 256; j++)     // cycle all 256 colors in the wheel
  {
    for (int q = 0; q < 3; q++)
    {
      for (int i = 0; i < strip.numPixels(); i = i + 3)
      {
        strip.setPixelColor(i + q, Wheel( (i + j) % 255)); //turn every third pixel on
      }
      strip.show();
      delay(wait);
      for (int i = 0; i < strip.numPixels(); i = i + 3)
      {
        strip.setPixelColor(i + q, 0);      //turn every third pixel off
      }
    }
  }
}

// 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);
  }
}

yes it does , but still can't use the button to change the sequence.

many thanks .

I didn't notice all the stuff at the top of loop: you're calling all the various patterns unconditionally. Having removed that, this might be better:

#include <Adafruit_NeoPixel.h>

#define BUTTON_PIN   2    // Digital IO pin connected to the button.  This will be
// driven with a pull-up resistor so the switch should
// pull the pin to ground momentarily.  On a high -> low
// transition the button press logic will execute.

#define PIXEL_PIN    6   // Digital IO pin connected to the NeoPixels.

#define PIXEL_COUNT 24   // number of neopixel (change this accordingly)

// Parameter 1 = number of pixels in strip,  neopixel stick has 8
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_RGB     Pixels are wired for RGB bitstream
//   NEO_GRB     Pixels are wired for GRB bitstream, correct for neopixel stick
//   NEO_KHZ400  400 KHz bitstream (e.g. FLORA pixels)
//   NEO_KHZ800  800 KHz bitstream (e.g. High Density LED strip), correct for neopixel stick
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);

bool oldState = HIGH;
int showType = 0;

void setup()
{
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  strip.begin();
  strip.setBrightness(100);  // Lower brightness and save eyeballs!
  strip.show(); // Initialize all pixels to 'off'
}

void loop()
{
  // Get current button state.
  bool newState = digitalRead(BUTTON_PIN);
  // Check if state changed from high to low (button press).
  if (newState == LOW && oldState == HIGH)
  {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState = digitalRead(BUTTON_PIN);
    if (newState == LOW)
    {
      showType++;
      if (showType > 9)
        showType = 0;
    }
  }
  // Set the last button state to the old state.
  oldState = newState;
  startShow(showType);
}

void startShow(int i)
{
  switch (i)
  {
    case 0: colorWipe(strip.Color(0, 0, 0), 50);    // Black/off
      break;
    case 1: colorWipe(strip.Color(255, 255, 255), 50);  // White
      break;
    case 2: colorWipe(strip.Color(0, 100, 0), 50);  // Green
      break;
    case 3: colorWipe(strip.Color(255, 165, 0), 50);  // Orange
      break;
    case 4: colorWipe(strip.Color(255, 0, 0), 50); // Red
      break;
    case 5: colorWipe(strip.Color(0, 0, 255), 50); // Blue
      break;
    case 6: rainbow(20);
      break;
    case 7: rainbowCycle(20);
      break;
    case 8: theaterChaseRainbow(50);
      break;
  }
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait)
{
  for (uint16_t i = 0; i < strip.numPixels(); i++)
  {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

void rainbow(uint8_t wait)
{
  uint16_t i, j;
  delay(1000);
  while (true)
  {
    for (j = 0; j < 256; j++)
    {
      for (i = 0; i < strip.numPixels(); i++)
      {
        strip.setPixelColor(i, Wheel((i + j) & 255));
        if(digitalRead(BUTTON_PIN)==LOW)
          {
          delay(1000);
          return;
          }
      }
      strip.show();
      delay(1000);
    }
  }
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait)
{
  uint16_t i, j;
  for (j = 0; j < 256 * 5; j++)   // 5 cycles of all colors on wheel
  {
    for (i = 0; i < strip.numPixels(); i++)
    {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait)
{
  for (int j = 0; j < 256; j++)     // cycle all 256 colors in the wheel
  {
    for (int q = 0; q < 3; q++)
    {
      for (int i = 0; i < strip.numPixels(); i = i + 3)
      {
        strip.setPixelColor(i + q, Wheel( (i + j) % 255)); //turn every third pixel on
      }
      strip.show();
      delay(wait);
      for (int i = 0; i < strip.numPixels(); i = i + 3)
      {
        strip.setPixelColor(i + q, 0);      //turn every third pixel off
      }
    }
  }
}

// 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);
  }
}

good morning ,

Wauw , I was very surprised to find another code...

And.... it's almost perfect

if i press the button once , nothing happens .
At the 2 nd press I get my solid white color .
At the 3 th press , nothing happens anymore . The solid white keeps white.

I have to press like 20 times or more on the button before it gets to green color.
The same for the next solid colors. I have to push like 20 times on the button before I get the next color.

Before the rainbow cycles begin , i have to press the button a lot of times .

i can toggle all the different styles , but i need to push that button a lot.

I appreciate the effort . if you're feeling up to it to tweak it , that would be awesome

I had changed the code to send whatever the current pattern was continuously. That was a bad idea because of the delay in colorWipe, which I believe is why the button is so unresponsive. This version returns to the prior behavior.

#include <Adafruit_NeoPixel.h>
const unsigned long ButtonDelay = 500;

#define BUTTON_PIN   2    // Digital IO pin connected to the button.  This will be
// driven with a pull-up resistor so the switch should
// pull the pin to ground momentarily.  On a high -> low
// transition the button press logic will execute.

#define PIXEL_PIN    6   // Digital IO pin connected to the NeoPixels.

#define PIXEL_COUNT 24   // number of neopixel (change this accordingly)

// Parameter 1 = number of pixels in strip,  neopixel stick has 8
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_RGB     Pixels are wired for RGB bitstream
//   NEO_GRB     Pixels are wired for GRB bitstream, correct for neopixel stick
//   NEO_KHZ400  400 KHz bitstream (e.g. FLORA pixels)
//   NEO_KHZ800  800 KHz bitstream (e.g. High Density LED strip), correct for neopixel stick
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);

bool oldState = HIGH;
int showType = 0;

void setup()
{
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  strip.begin();
  strip.setBrightness(100);  // Lower brightness and save eyeballs!
  strip.show(); // Initialize all pixels to 'off'
}

void loop()
{
  // Get current button state.
  bool newState = digitalRead(BUTTON_PIN);
  // Check if state changed from high to low (button press).
  if (newState == LOW && oldState == HIGH)
  {
    // Short delay to debounce button.
    delay(20);
    // Check if button is still low after debounce.
    newState = digitalRead(BUTTON_PIN);
    if (newState == LOW)
    {
      showType++;
      if (showType > 8)
        showType = 0;
      startShow(showType);
    }
  }
  // Set the last button state to the old state.
  oldState = newState;

}

void startShow(int i)
{
  switch (i)
  {
    case 0: colorWipe(strip.Color(0, 0, 0), 50);    // Black/off
      break;
    case 1: colorWipe(strip.Color(255, 255, 255), 50);  // White
      break;
    case 2: colorWipe(strip.Color(0, 100, 0), 50);  // Green
      break;
    case 3: colorWipe(strip.Color(255, 165, 0), 50);  // Orange
      break;
    case 4: colorWipe(strip.Color(255, 0, 0), 50); // Red
      break;
    case 5: colorWipe(strip.Color(0, 0, 255), 50); // Blue
      break;
    case 6: rainbow(20);
      break;
    case 7: rainbowCycle(20);
      break;
    case 8: theaterChaseRainbow(50);
      break;
  }
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait)
{
  for (uint16_t i = 0; i < strip.numPixels(); i++)
  {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

void rainbow(uint8_t wait)
{
  uint16_t i, j;
  delay(ButtonDelay);
  while (true)
  {
    for (j = 0; j < 256; j++)
    {
      for (i = 0; i < strip.numPixels(); i++)
      {
        strip.setPixelColor(i, Wheel((i + j) & 255));
        if(digitalRead(BUTTON_PIN)==LOW)
          {
          delay(ButtonDelay);
          return;
          }
      }
      strip.show();
      delay(1000);
    }
  }
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait)
{
  uint16_t i, j;
  for (j = 0; j < 256 * 5; j++)   // 5 cycles of all colors on wheel
  {
    for (i = 0; i < strip.numPixels(); i++)
    {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait)
{
  for (int j = 0; j < 256; j++)     // cycle all 256 colors in the wheel
  {
    for (int q = 0; q < 3; q++)
    {
      for (int i = 0; i < strip.numPixels(); i = i + 3)
      {
        strip.setPixelColor(i + q, Wheel( (i + j) % 255)); //turn every third pixel on
      }
      strip.show();
      delay(wait);
      for (int i = 0; i < strip.numPixels(); i = i + 3)
      {
        strip.setPixelColor(i + q, 0);      //turn every third pixel off
      }
    }
  }
}

// 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);
  }
}