Why on eart dont this work - 2 x buttons ?

Hi, today my hair is going grey.

I really dont understand why this code dont work, nothing on serial when pressing buttons

buttons is connected between GND and GPIO.

I run this on an ESP32 OLED LiLigo

const int nextPin = 34;     // les next kube data, knapp til høyre
const int previousPin = 35;   // les previous kube data, knapp til venstre

int previousButtonState;                 // the current reading from the input pin
int lastpreviousButtonState = HIGH;       // the previous reading from the input pin
unsigned long lastpreviousDebounceTime = 0;  // the last time the output pin was toggled

int nextButtonState;                   // the current reading from the input pin
int lastnextButtonState = HIGH;         // the previous reading from the input pin
unsigned long lastnextDebounceTime = 0;    // the last time the output pin was toggled

unsigned long debounceDelay = 50;       // the debounce time; increase if the output flickers

void setup() {
  pinMode(previousPin, INPUT_PULLUP);
  pinMode(nextPin, INPUT_PULLUP);
  Serial.begin(115200);                 // Start seriell kommunikasjon for debugging
}

void loop() {
  // read the state of the switches into local variables:
  int previousReading = digitalRead(previousPin);
  int nextReading = digitalRead(nextPin);

  // Debounce previousPin
  if (previousReading != lastpreviousButtonState) {
    lastpreviousDebounceTime = millis();
  }
  
  if ((millis() - lastpreviousDebounceTime) > debounceDelay) {
    if (previousReading != previousButtonState) {
      previousButtonState = previousReading;
      if (previousButtonState == LOW) {
        Serial.println("Previous button");
      }
    }
  }
  lastpreviousButtonState = previousReading;

  // Debounce nextPin
  if (nextReading != lastnextButtonState) {
    lastnextDebounceTime = millis();
  }

  if ((millis() - lastnextDebounceTime) > debounceDelay) {
    if (nextReading != nextButtonState) {
      nextButtonState = nextReading;
      if (nextButtonState == LOW) {
        Serial.println("Next button");
      }
    }
  }
  lastnextButtonState = nextReading;
}

Do pins 34 and 35 support INPUT_PULLUP ?

You should read this to prevent loosing hair

>No....

Thanks

I have changed pins and now it works.

Thanks, I will store the Random link for next time, to prevent hair loss :wink:

@UKHeliBob gave ma a good tip.

I have studied quite a bit GPIOs for ESP WROOM, youtube -> Spiess.
For this OLED ESP there is SD card enabled, LoRa enabled and OLED enabled that gives an extra challenge for me.

image