Creare un menù 4 pulsanti con OLED SSD1306

S'intende che la pulsantiera funziona correttamente e l'ho testata con questo codice:

#include "Wire.h"
#include "Adafruit_GFX.h"
#include "OakOLED.h"


/////// GLOBALS //////

OakOLED oled;

///////////////////////

const int buttonOK = D5;     // number of pushbutton 1 pin OK
int buttonStateOK = LOW;       // set the default variable value for pushbutton1 status
const int buttonDOWN = D6;     // number of pushbutton 2 pin GIU'
int buttonStateDOWN = LOW;       // set the default variable value for pushbutton2 status
const int buttonUP = D7;     // number of pushbutton 3 pin SU'
int buttonStateUP = LOW;       // set the default variable value for pushbutton3 status
const int buttonESC = D8;     // number of pushbutton 4 pin ESC
int buttonStateESC = LOW;       // set the default variable value for pushbutton4 status



void setup() {                  // Set Pins to Outputs Or Inputs
  pinMode(buttonOK, INPUT);   // initialize the pushbutton pins as an inputs:
  pinMode(buttonDOWN, INPUT);   // initialize the pushbutton pins as an inputs:
  pinMode(buttonUP, INPUT);   // initialize the pushbutton pins as an inputs:
  pinMode(buttonESC, INPUT);   // initialize the pushbutton pins as an inputs:

  Serial.begin(115200); // initialize serial communication at 115200 baud
  oled.begin();
  oled.setTextSize(1);
  oled.setTextColor(1);

  oled.setCursor(30, 0);
  oled.clearDisplay();
  oled.print("TEST BUTTON");
  oled.setCursor(0, 25);
  oled.print("WAIT A BUTTON PRESS");
  oled.display();
  Serial.println("WAIT A BUTTON PRESS");
  delay(5000);
}


void loop() {
  buttonStateOK = digitalRead(buttonOK);  // read current states of the pushbutton value:
  buttonStateDOWN = digitalRead(buttonDOWN);  // read current states of the pushbutton value:
  buttonStateUP = digitalRead(buttonUP);  // read current states of the pushbutton value:
  buttonStateESC = digitalRead(buttonESC);  // read current states of the pushbutton value:

  // check if the pushbutton is pressed buttonState# == HIGH/LOW
  // if pressed change buttonState == HIGH to turn on ledPin#
  // else if buttonState == LOW then digitalWrite(ledPin#, LOW) Keeps Led off.


  if (buttonStateOK == HIGH) {    //check buttonState
    oled.setCursor(30, 0);
    oled.clearDisplay();
    oled.print("TEST BUTTON");
    oled.setCursor(0, 25);
    oled.println("BUTTON PRESSED:");
    oled.print("    D5 - OK");
    oled.display();
    Serial.println("BUTTON PRESSED: D5 - OK"); //Print buttonState to serial
    delay(200);
  }

  if (buttonStateDOWN == HIGH) {   //check buttonState
    oled.setCursor(30, 0);
    oled.clearDisplay();
    oled.print("TEST BUTTON");
    oled.setCursor(0, 25);
    oled.println("BUTTON PRESSED:");
    oled.print("    D6 - DOWN");
    oled.display();
    Serial.println("BUTTON PRESSED: D6 - DOWN"); //Print buttonState to serial
    oled.display();
    delay(200);
  }

  if (buttonStateUP == HIGH) {   //check buttonState
    oled.setCursor(30, 0);
    oled.clearDisplay();
    oled.print("TEST BUTTON");
    oled.setCursor(0, 25);
    oled.println("BUTTON PRESSED:");
    oled.print("    D7 - UP");
    oled.display();
    Serial.println("BUTTON PRESSED: D7 - UP"); //Print buttonState to serial
    oled.display();
    delay(200);
  }
  if (buttonStateESC == HIGH) {   //check buttonState
    oled.setCursor(30, 0);
    oled.clearDisplay();
    oled.print("TEST BUTTON");      //Cancella Schermo lcd
    oled.setCursor(0, 25);
    oled.println("BUTTON PRESSED:");
    oled.print("    D8 - ESC");
    oled.display();
    Serial.println("BUTTON PRESSED: D8 - ESC"); //Print buttonState to serial
    oled.display();
    delay(200);
  }

  oled.setCursor(30, 0);
  oled.clearDisplay();
  oled.print("TEST BUTTON");
  oled.setCursor(0, 25);
  oled.print("ALL BUTTONS RELEASED");
  oled.display();
}