Esplora's buzzer loop

Hi guys,
I'm trying to do a sort of phone with the arduino Esplora. I set that when the button to navigate is pressed, it makes a sound and add (or remove) 1 to a variable. Then, it chekcs the variable value to mark the various funcitionalities. The problem is that the buzzer keeps making sounds and only the first functionality is green. Also, I tried to initialise a Serial Monitor showing the value of "posizionemenu", but it remains 0.
Thanks in advance
Here's the code

#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>
#include <Esplora.h>


#define cs 7
#define rst 1
#define dc 0
#define SD_CS 8
Adafruit_ST7735 tft = Adafruit_ST7735(cs, dc, rst);
#define sclk 15
#define mosi 16
int posizionemenu = 0;

 int scendi = Esplora.readButton(SWITCH_DOWN);
  int sali = Esplora.readButton(SWITCH_UP);
  int seleziona = Esplora.readButton(SWITCH_RIGHT);
  int indietro = Esplora.readButton(SWITCH_LEFT);
boolean menu = true;
void setup() {

  
  tft.initR(INITR_BLACKTAB);
  tft.fillScreen(ST7735_BLACK);
  tft.setRotation(1);
   
  tft.setCursor(0,0);
  tft.setTextColor(ST7735_WHITE);
  tft.print("music");
  tft.setCursor(0,25);
  tft.print("photos");
  tft.setCursor(0,50);
  tft.print("phone");
  tft.setCursor(0,75);
  tft.print("SMS");
  Serial.begin(9600);
  
    
}

void loop() {
  
  if(scendi == LOW){
    posizionemenu++;
    Esplora.tone(1000);
    delay(100);
    Esplora.noTone();
  }
  if(sali==LOW){
    posizionemenu--;
    Esplora.tone(1000);
    delay(100);
    Esplora.noTone();
  } 
  Serial.print(posizionemenu);
  delay(1000);
 

  
  
  
    
  

  



  if(posizionemenu==0){
    tft.setCursor(0,0);
    tft.setTextColor(ST7735_GREEN);
    tft.print("music");
  }
  else{
    tft.setCursor(0,0);
    tft.setTextColor(ST7735_WHITE);
    tft.print("music");
  }
  
  if(posizionemenu==1){
    tft.setCursor(0,25);
    tft.setTextColor(ST7735_GREEN);
    tft.print("photos");
  }
  else{
    tft.setCursor(0,25);
    tft.setTextColor(ST7735_WHITE);
    tft.print("photos");
  }
  if(posizionemenu==2){
    tft.setCursor(0,50);
    tft.setTextColor(ST7735_GREEN);
    tft.print("phone");
  }
  else{
    tft.setCursor(0,50);
    tft.setTextColor(ST7735_WHITE);
    tft.print("phone");
  }

  if (posizionemenu==3){
    tft.setCursor(0,75);
    tft.setTextColor(ST7735_GREEN);
    tft.print("SMS");
  }
  else{
   tft.setCursor(0,75);
    tft.setTextColor(ST7735_WHITE);
    tft.print("SMS");
  }
  if (posizionemenu==4){
    posizionemenu=3;
  }
  if (posizionemenu<0){
    posizionemenu=0;
  }
  
  
  
}

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read.

Please remove unnecessary blank lines from your code before posting to the forum. One or two to separate code into sections is fine but large spaces for no reason just make for more scrolling when we're trying to read your code.

You're not going about the development of this project in the right way. You need to do it in stages. Get each component of the project working individually before moving to the next one:

  • Write a sketch that beeps the buzzer once a second.
  • Write a sketch that prints to the serial monitor when you press each button
  • Write a sketch that prints "Hello world" to the LCD

These can be very simple sketches so they won't take long. You may be able to use the examples included with the IDE. Make sure you understand what every line of code does before you move on to the next one. Save each sketch to use for testing later if you need to do some troubleshooting.

Here's a hint. You need to be reading the button states in loop().

Thanks for your help!
btw, I already know how to use these components and what means every line of code. Time ago the code worked properly at the first try, then I tried to add the functionality of exploring various sections, and all messed up. Now I'm going to try your suggestion :slight_smile: