button to change mode?

I have a setup id like to impliment. i have a few different codes that i would like to make into one, and switch modes with a pushbutton. the code i have is this

#include <Button.h>

Button button = Button(12);

void setup(){
 pinMode(9,OUTPUT); 
 pinMode(10,OUTPUT);
 pinMode(11,OUTPUT);
   Serial.begin(115200);
 
}
byte pressCount = 0;
void loop(){
Serial.println(pressCount);
 if (button.uniquePress())
pressCount++;

switch(pressCount)
       
       {case 1:
         
         digitalWrite(9,HIGH);
       digitalWrite(10,LOW);
       digitalWrite(11,LOW);
 
 break;

 case 2:
 

       digitalWrite(9,LOW);
       digitalWrite(10,HIGH);
       digitalWrite(11,LOW);
 
  break;
  case 3:

  digitalWrite(10, HIGH);  
  delay(50);              
  digitalWrite(10, LOW); 
  delay(30);  
  digitalWrite(10, HIGH); 
  delay(50);             
  digitalWrite(10, LOW); 
  delay(10);
  digitalWrite(11, HIGH);    
  delay(50);    
  digitalWrite(11, LOW);        
  delay(30);  
  digitalWrite(11, HIGH);    
  delay(50);    
  digitalWrite(11, LOW);       
  delay(10);
pressCount = 0;
      break;  
 }


  }

this is only one part on case 3 that i made as a police light setup. anyway when i try it out the lights dont loop and i cant figure out how to make it loop any ideas im sure im doing something simple and wrong thanks guys.

If you want it to loop, you shouldn't be telling it to return to state 0 when it's done. You want it to reset to 0 on the next button press, so you should be checking for what state it's in when you see a button press, and resetting it to 0 if it's "out-of-range"

Be warned though, you're going to have a very small window to actually press the button because of all the delays in your code. I would consider re-implementing your code to not use them. See the Blink Without Delay code for an example on how to do that. While the idea may seem like a simple task, implementing it in code can get very complex, very quickly.

thank you so much i feel dumb i didnt see that, but it works now im gonna redo the code with the blink without delay like you said. i have another code that i want to add, the problem is that i get errors the code works with a mic and amp as well. the code is

// Rainbow color changing RGB leds example
// I am using common cathode RGB leds
int PIN_RED = 9;
int PIN_GREEN = 11;
int PIN_BLUE = 10;
int counter = 0;
int potPin = 3;    // select the input pin for sound sensor
int val = 0;
int amp = 0;
float brit = 0;

// Number of colors used for animating, higher = smoother and slower animation)
int numColors = 1220;

  // The combination of numColors and animationDelay determines the
  // animation speed, I recommend a higher number of colors if you want
  // to slow down the animation. Higher number of colors = smoother color changing.
int animationDelay = 1; // number milliseconds before RGB LED changes to next color

void setup() {
  pinMode(PIN_RED, OUTPUT);
  pinMode(PIN_BLUE, OUTPUT);
  pinMode(PIN_GREEN, OUTPUT);
  Serial.begin(115200);
}
  

void loop() {
    float brightness = brit;
    val = analogRead(potPin);
     Serial.println(amp);
     
  amp = (val >= 512) ? val - 512 : 512 - val;
  if (amp > 120) {
  brit = 1;
  } else if (amp < 120) {
  brit = .1;
  }
  // This part takes care of displaying the
  // color changing in reverse by counting backwards if counter
  // is above the number of available colors  
  float colorNumber = counter > numColors ? counter - numColors: counter;
  
  // Play with the saturation and brightness values
  // to see what they do
  float saturation = 1; // Between 0 and 1 (0 = gray, 1 = full color)
 // Between 0 and 1 (0 = dark, 1 is full brightness)
  float hue = (colorNumber / float(numColors)) * 360; // Number between 0 and 360
  long color = HSBtoRGB(hue, saturation, brightness);
  
  // Get the red, blue and green parts from generated color
  int red = color >> 16 & 255;
  int green = color >> 8 & 255;
  int blue = color & 255;

  setColor(red, green, blue);
  
  // Counter can never be greater then 2 times the number of available colors
  // the colorNumber = line above takes care of counting backwards (nicely looping animation)
  // when counter is larger then the number of available colors
  counter = (counter + 1) % (numColors * 2);
  
  // If you uncomment this line the color changing starts from the
  // beginning when it reaches the end (animation only plays forward)
  // counter = (counter + 1) % (numColors);

  delay(animationDelay);
}

void setColor (unsigned char red, unsigned char green, unsigned char blue)
{
    analogWrite(PIN_RED, red);
    analogWrite(PIN_GREEN, green);
    analogWrite(PIN_BLUE, blue);
}

long HSBtoRGB(float _hue, float _sat, float _brightness) {
    float red = 0.0;
    float green = 0.0;
    float blue = 0.0;
    
    if (_sat == 0.0) {
        red = _brightness;
        green = _brightness;
        blue = _brightness;
    } else {
        if (_hue == 360.0) {
            _hue = 0;
        }

        int slice = _hue / 60.0;
        float hue_frac = (_hue / 60.0) - slice;

        float aa = _brightness * (1.0 - _sat);
        float bb = _brightness * (1.0 - _sat * hue_frac);
        float cc = _brightness * (1.0 - _sat * (1.0 - hue_frac));
        
        switch(slice) {
            case 0:
                red = _brightness;
                green = cc;
                blue = aa;
                break;
            case 1:
                red = bb;
                green = _brightness;
                blue = aa;
                break;
            case 2:
                red = aa;
                green = _brightness;
                blue = cc;
                break;
            case 3:
                red = aa;
                green = bb;
                blue = _brightness;
                break;
            case 4:
                red = cc;
                green = aa;
                blue = _brightness;
                break;
            case 5:
                red = _brightness;
                green = aa;
                blue = bb;
                break;
            default:
                red = 0.0;
                green = 0.0;
                blue = 0.0;
                break;
        }
    }

    long ired = red * 255.0;
    long igreen = green * 255.0;
    long iblue = blue * 255.0;
    
    return long((ired << 16) | (igreen << 8) | (iblue));
}

now this code isnt completly mine its parts from other ppl but i tried to make it work in the uniquepress and it doesnt work any help?

update

I got the code to work thank you for your help i just needed to put the right peices in the correct place im going to look up the out of range command and see if i can impliment that thanks again