ATtiny85 analog pin & interrupts

Hi! I'm working on a project and I have some issues with the interrupts. I have 4 buttons connected to A2 on the ATtiny85. When one of them is pressed, it should trigger an interrupt and do stuff specific to the button pressed. The problem is that kinda works with the below code but after 5 minutes it only responds to a single button (button4). The buttons generate different voltages between pin A2 and ground, I've built a voltage divider using resistors.

#include <avr/interrupt.h>

// Pin definitions
const int buttonPin = A2;  // Analog pin A2 (physical pin 3)
const int ledPin = 3;      // PB3 (physical pin 2)

// Voltage levels corresponding to button presses
const int button1Threshold = 463;  // Threshold for Button 1 (1.96V) og 500  1k ohm                       1.96
const int button2Threshold = 320;  // Threshold for Button 2 (1.30V) og 330`   2k ohm                          1.30
const int button3Threshold = 209; // Threshold for Button3 (0.90V) resistor 3K                      0.90
const int button4Threshold = 637; // Threshold for Button3 (2.60)  resistor 500 ohm                 2.60


volatile bool button1Pressed = false;
volatile bool button2Pressed = false;
volatile bool button3Pressed = false;
volatile bool button4Pressed = false;
volatile bool sleepMode = false; // Flag to indicate sleep mode status

void setup() {

  // Initialize the LED pin as an output
  pinMode(ledPin, OUTPUT);

  // Enable pin change interrupt on PB4
  
  GIMSK |= (1 << PCIE);     // Enable Pin Change Interrupts
  PCMSK |= (1 << PCINT2);
  PCMSK |= (1 << PCINT4);
  PCMSK |= (1 << PCINT1);
  PCMSK |= (1 << PCINT0);   
  PCMSK |= (1 << PCINT5);
  //PCMSK |= (1 << PCINT3);

  sei();                    // Enable global interrupts


  // Put the ATtiny85 to sleep
  MCUCR = (1 << SM1) | (1 << SE);  // Set sleep mode to power down and enables the MC to be put in sleep mode
  asm("sleep");
}

void loop() {
  // If sleep mode is set, put the ATtiny85 to sleep
  if (sleepMode) {
    
    // Enable sleep mode
    MCUCR |= (1 << SE);

    // Enter sleep mode (Ensure we are in sleep mode until an interrupt wakes us up)
    asm("sleep");

    // Disable sleep mode after waking up
    MCUCR &= ~(1 << SE);

    // The program continues from here after waking up
    // Clear sleep mode flag
    sleepMode = false;
    
    
  }

  if (button1Pressed) {
    // Debounce the button press by adding a small delay
    delay(50); // 50 ms delay

    // Check if the button is still pressed after the delay
    if (analogRead(buttonPin) >= button1Threshold && analogRead(buttonPin) < button4Threshold) {
      // Perform the action for button 1
       // Send command
    }

    // Reset the button pressed flag
    button1Pressed = false;

    // Set the sleep mode flag
    sleepMode = true;

    
  }

  if (button2Pressed) {
    // Debounce the button press by adding a small delay
    delay(50); // 50 ms delay

    // Check if the button is still pressed after the delay
    if (analogRead(buttonPin) >= button2Threshold && analogRead(buttonPin) < button1Threshold) {
      // Perform the action for button 2
       // Send command
    }

    // Reset the button pressed flag
    button2Pressed = false;

    // Set the sleep mode flag
    sleepMode = true;

    
  }
  if (button3Pressed) {
    // Debounce the button press by adding a small delay
    delay(50); // 50 ms delay

    // Check if the button is still pressed after the delay
    if (analogRead(buttonPin) >= button3Threshold && analogRead(buttonPin) < button2Threshold) {
      // Perform the action for button 2
       // Send command
    }

    // Reset the button pressed flag
    button3Pressed = false;

    // Set the sleep mode flag
    sleepMode = true;

    
  }
  if (button4Pressed) {
    // Debounce the button press by adding a small delay
    delay(50); // 50 ms delay

    // Check if the button is still pressed after the delay
    if (analogRead(buttonPin) >= button4Threshold) {
      // Perform the action for button 2
       // Send command
    }

    // Reset the button pressed flag
    button4Pressed = false;

    // Set the sleep mode flag
    sleepMode = true;

    
  }
}

// Interrupt Service Routine (ISR) for pin change interrupt
ISR(PCINT0_vect) {
  //ADCSRA |= (1 << ADEN);
  // Read the analog value of the button pin
  int analogValue = analogRead(buttonPin);

  if (analogValue >= button4Threshold) {
    // Set the button 4 pressed flag
    button4Pressed = true;
  }
   if (analogValue >= button1Threshold && analogValue < button4Threshold) {
    // Set the button 1 pressed flag
    
    button1Pressed = true;
  }
   if (analogValue >= button2Threshold && analogValue < button1Threshold) {
    // Set the button 2 pressed flag
    
    button2Pressed = true;
  }
  if (analogValue >= button3Threshold && analogValue < button2Threshold) {
    // Set the button 3 pressed flag
     // Send command
    button3Pressed = true;

  }
}

I've enabled Pin Change interrupts on so many pins because if I enable only the PCINT4 which is tied to A2 only button4 is working . If I enable only PCINT2 for some reason the buttons only work for a one second after the mc powers up, then only the button4 is working.
Any idea how I can fix this?

Take a look into Arduino/reference/interrupt.
Usually digital pins can interrupt on raising, falling or changing signals.
Never heard about interrupts on analog signals.
Interrupt looks like being a miracle solution among ignorant people. Detecting button pressing is easily done in loop(() asuming correctly written code.

What is the analogValue if no button is pressed?
Using interrupts to detect button presses is not the right approach, to a processor running at 8 or 16MHz, a human pressing a button looks like grass growing and switch bounce will cause all kinds of mysterious faults.

  1. The voltage at the pin has to go above 0.6 * Vcc to register the pin change.

  2. I'm pretty sure that once it is configured as an analog input it won't work anymore for pin change.

If all of the analog values are above the threshold then it might be possible to leave the pin configured as a digital pin and just have the ISR wake up the MCU and register that "something" was pressed at which point it can enter the code and set the pin up as an analog input and read the actual value to determine which pin.

You might also be able to it by enabling the pullup resistor on D4 (A2) . Each button would connect a different value resistor between the pin and ground. When a button is pressed, the pin is in a voltage divider between the resistor you have connected to it and the pullup resistor (~30k). The resistors you add should be strong enough to pull the pin low enough to change the pin state from high to low and thus wake the MCU. Then use analogRead() to determine which button was pressed.
The code has, incidentally, a ChatGPT look to it.