First code/idea contribution. Video is poor but will give the idea of what I

First code/idea contribution. Video is poor but will give the idea of what I am doing, code is functional but can easily be improved.

After seeing the LED VU meters and simulations of bouncing balls, fire, etc. I decided to make my own that incorporated a pushbutton switch. Easy to do even for someone who hasnt coded for dollars since 1985 thanks to the great numbers of people who generously share ideas and code.

So, my contribution is one I havent seen yet out here for people who are making these light shows. It is an indicator of what routine you are running. i.e. vu1, vu2, bouncing balls, fire1, fire2, etc. My display has no VU feature but does have a lot of routines I switch between with a momentary pushbutton. The code will interrupt the routine and display a number of LEDS that correspond to the routine number. THere is a two second timeout and a single press doesn’t change the routine, only display the routine. The entire routine is below along with a link to the youtube video.

Paul

void checkButton() {
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
buttonValueDisplayed = 1;
buttonDisplayTimer = millis();

for ( int k = 0; k < NUM_LEDS; k++) {
  ledsTemp[k] = leds[k];
}
FastLED.clear();
digitalWrite(ledPin, HIGH);
int displayedButtonValue = 0;                     // First time through no value is displayed.
int i = 0;                                        // LCV
int j = 0;                                        // LCV
do {                                               // Display button count for 2 seconds since last press.
  while (displayedButtonValue != buttonValue) {    // Prepare button display if not yet displayed.
    FastLED.clear();
    i = (NUM_LEDS - buttonValue) / 2;
    for (j = 0; j < buttonValue; j++) {
      if ((j + 1) % 5 == 0 ) {
        leds[i] = CRGB ::Blue;
      } else {
        leds[i] = CRGB ::White;
      }
      i = i + 1;
    }
    FastLED.show();
    displayedButtonValue = buttonValue;
    delay(20);
  }
  buttonState = digitalRead(buttonPin);
  while (buttonState == HIGH) {                  // Will sit here until button is released.
    buttonState = digitalRead(buttonPin);
  }
  delay(20);                                     // This is here because it may help with a bouncing contact.
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH) {                     // If button is pressed again, increment button value and reset 2 second timer.
    buttonValue = buttonValue + 1;
    buttonValueChanged = 1;                                   // flag that indicates the button value has changed.
    if ( buttonValue > maxButtonValue ) {
      buttonValue = 1;
    }
    buttonDisplayTimer = millis();
  }
} while ((millis() - buttonDisplayTimer) < buttonDisplayDelay);
FastLED.clear();
for ( int k = 0; k < NUM_LEDS; k++) {
  leds[k] = ledsTemp[k];
}

}
digitalWrite(ledPin, LOW);

}

Thanks for sharing.