Qwiic Button and LED Stick- Prevent Button Hold down event

For my project I have a Qwiic Button and Qwiip LED stick. I want to be able to cycle the LED stick from Green, Yellow and Red by pressing the button . As a total newbie to Arduino’s I am running into an issue with the button being held down and cycling through each color in a few miliseconds.

here is my code I’m open to any suggestions

QwiicButton button;

LED LEDStick; //Create an object of the LED class

int countPush = 1;// count the number of pushes

int lastcountPush;

unsigned long debounceDelay = 250; // ignore any additional button presses after the first press for this time

uint16_t brightness = 250; //The maximum brightness of the pulsing LED. Can be between 0 (min) and 255 (max)

uint16_t cycleTime = 1000; //The total time for the pulse to take. Set to a bigger number for a slower pulse, or a smaller number for a faster pulse

uint16_t offTime = 200; //The total time to stay off between pulses. Set to 0 to be pulsing continuously.

void setup() {

Wire.begin();

Serial.begin(115200);

//Start up communication with the LED Stick

if (LEDStick.begin() == false) {

Serial.println(“Qwiic LED Stick failed to begin. Please check wiring and try again!”);

while (1);

}

if (button.begin() == false) {

Serial.println(“Device did not acknowledge! Freezing.”);

while (1);

}

Serial.println(“Button acknowledged.”);

Serial.println(“Qwiic LED Stick ready!”);

}

void loop() {

if (button.timeSinceLastPress() > debounceDelay && button.isPressed() == true) // If the time from the last push is less than debounce delay of 250ms and the button is pushed add one to the pushCount

{

Serial.println(“The button is pressed!”);

Serial.print(button.timeSinceLastPress()/1000.0); // print the time since the button was last pressed

button.LEDon(brightness);

countPush++; // Count the number of times the button has been pushed

Serial.println(countPush);

delay(100);

}

else

{

Serial.println(“BUTTON IS NOT PRESSED”);

}

switch(countPush){ // use the countPush to cycle between Green, Yellow and Red

case 1: // Turn the LED to Green for countPush 1

LEDStick.setLEDColor(00, 10, 00);

Serial.println(countPush);

Serial.println(“green”);

delay(100);

break;

case 2: // Turn the LED to Yellow for countPush 2

LEDStick.setLEDColor(10, 10, 00);

Serial.println(countPush);

Serial.println(“yellow”);

delay(100);

break;

case 3: // Turn the LED to Red for countPush 3

LEDStick.setLEDColor(10, 00, 00);

Serial.println(countPush);

Serial.println(“red”);

delay(100);

break;

default: // If the pushcount is higher than 3 change the pushCount to 1 so they cycle start over

countPush = 1;

Serial.println(countPush);

Serial.println(“Default”);

delay(100);

break;

}

}

You may need to alter the debounce time, or the cycle time to better match your use-case