Problem with the buton together with the potiometer

[SOLVED]

Since you configured the input pin with INPUT_PULLUP I'll assume your button is wired to GND and the input. If that is the case then your input is active LOW. This means the input remains HIGH until the button is pressed. In your code if the input is HIGH then it is stuck waiting for the input to go to LOW. That would explain why nothing happens when you include the button input.

    if(digitalRead(buttonPin) == HIGH)
    {
      
        delay(10);
        while(digitalRead(buttonPin) == HIGH)
        {
            
        }
        mode();
    }

ToddL1962:
Since you configured the input pin with INPUT_PULLUP I'll assume your button is wired to GND and the input. If that is the case then your input is active LOW. This means the input remains HIGH until the button is pressed. In your code if the input is HIGH then it is stuck waiting for the input to go to LOW. That would explain why nothing happens when you include the button input.

    if(digitalRead(buttonPin) == HIGH)

{
     
        delay(10);
        while(digitalRead(buttonPin) == HIGH)
        {
           
        }
        mode();
    }

You were right, thanks