Arduino Programming gets lost after multiple function calls

I'm somewhat new to Arduino and programming, but have had experience for 6 months of trial and error and research. I have a project that has a lot of parts and a lot of programming and my program has stopped working, I think i know whats wrong, but I'm not sure how to fix it.

My project in short is an arduino uno with a GLCD and sensors with a complicated menu system.
Data comes the sensors go to the GLCD and with buttons to go through various menus. I'm going to post my code a little stripped down without all the print commands to save space and I'll also exclude all the sensor codes too.

/*00000000      Libraries included    00000000*/
#include <SerialGraphicLCD.h>
#include <SoftwareSerial.h>
#include "DHT.h"
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP183.h>
#include <DS3234.h>

/*00000000      GLCD screen size  00000000*/
#define maxX 127//159 
#define maxY 63 //127

/*00000000   BMPsensor  00000000*/
#define BMP183_CLK  13  // AKA CLK
#define BMP183_SDO  12  // AKA MISO
#define BMP183_SDI  11  // AKA MOSI
#define BMP183_CS   4
Adafruit_BMP183 bmp = Adafruit_BMP183(BMP183_CLK, BMP183_SDO, BMP183_SDI, BMP183_CS);
volatile float pressure_mmHg;
volatile float pressurepascal;
volatile float Altitude;
float last_microsBMP;

/*00000000   DeadOn time chip  00000000*/
volatile int TimeDate [7]; //second,minute,hour,null,day,month,year
const int CSpin=10;
const int MOSIpin=11;
const int MISOpin=12;
const int CLKpin=13;
float last_microsTime;
/*00000000    DHT sensor stuff    00000000*/
#define DHTPIN 9     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE);
volatile float humidity=0;
volatile float airtemp=0;
volatile float heatindex=0;
volatile float last_microsDHT;

/*00000000    variables for debounce    00000000*/
long debouncing_time = 250; //Debouncing delay coefficent
long last_micros;
int state = LOW;

/*00000000    variables for menus    00000000*/
int optionspotx=0;
int optionspoty=0;
int enterbutton=0;
int backbutton=0;
int BUTTONLEFT=false;
int BUTTONRIGHT=false;
int BUTTONENTER=false;
int BUTTONBACK=false;
int BUTTONEXIT=false;
int BUTTON10=false;
int menustack[6]={1,0,0,0,0,0}; //array acting as stack for menu porder when hopping from one menu to the other.
int currentmenuspot=1;         // set array size to number of menus desired
int prevmenuspot=1;
int menustackspot=0;
int menunumber;
volatile long BUTTON_micros=0;
int SELECTORSPOT=0;

/*00000000    LCD class declaration    00000000*/
LCD LCD;

/*00000000    CoSensor declaration    00000000*/
volatile int CoCode;
volatile int CoLevel;
float last_microsCO;
/*00000000    SETUP    00000000*/

void setup()
{
  pinMode(5, INPUT_PULLUP);     //button on pin 5
  pinMode(6, INPUT_PULLUP);
  pinMode(7, INPUT_PULLUP);
  pinMode(8, INPUT_PULLUP);
  
  attachInterrupt(0, debounce, FALLING); //interrupt
  
//  pinMode(ledPin13, OUTPUT);   // pin 13 on board LED

  RTC.configure(MOSIpin,MISOpin,CLKpin,CSpin);
//  RTC.setDateTime(12,8,2014,23,25,0); // RTC.setDateTime(int d, int mo, int y, int h, int mi, int s);
  dht.begin();
  bmp.begin();

//RTC.setDateTime(24, 10, 2014, 23, 17, 0); // int d, int mo, int y, int h, int mi, int s

  //splash screen
  LCD.setBacklight(20);
  LCD.clearScreen();
  LCD.setHome();
  LCD.printStr(" Program starts in "); //displays "program is starting in 5/4/3/2/1 etc"
    for(int i = 5; i >= 0; i--) 
      {
        LCD.setX(113);
        LCD.setY(0);
        LCD.printNum(i);
        delay(500);
      } 
  LCD.clearScreen(); 
  delay(200);
}

/*00000000    LOOP    00000000*/

void loop()
{  

SensorUpdate();     //update all sensors including time
menu_start();

//MainMenuDisplay();
//menu_select();
//sensor_menu();
//time_menu();

}

void debounce() 
{
  if(((long)(micros() - last_micros) >= debouncing_time * 1000) || last_micros==0)
  {
    state = !state;
    //digitalWrite(13, state);
    last_micros = micros();
    buttontest();
    menu_button_action_reader();
  }
}

void buttontest()
{
    if(digitalRead(5)==LOW)
    {BUTTONLEFT=true;}
    
    if(digitalRead(6)==LOW)
    {BUTTONRIGHT=true;}
    
    if(digitalRead(7)==LOW)
    {BUTTONENTER=true;}
    
    if(digitalRead(8)==LOW)
    {BUTTONBACK=true;}    
    
    if(digitalRead(9)==LOW)
    {BUTTONEXIT=true;}    
    
    if(digitalRead(10)==LOW)
    {BUTTON10=true;}    
}

void menu_start()
{
 
 findsmenuspot(); //function call to get what current position is. Sends array to check it
 switch(currentmenuspot) //based on result opens the a menu.
   {case 1:  MainMenuDisplay();
     break;
    case 2:  /*sensor_menu()*/;
     break;
    case 3:  /*time_menu()*/;
     break;
    case 4:  /*Text()*/;
     break;
    }
 BOXSELECTOR();
}

/*00000000000000000000   Previous menu function   0000000000000000000000000*/
  
  
int prevmenu () //function to find what previous menu is
{
  for(int c=0; menustack[c]!=0; c++ ) //scans from array[0] until it finds a 0
      {
        currentmenuspot=menustack[c-1]; //saves number which is the menu to variable to be tested 
      }    

    if (menustack[currentmenuspot-1] !=1) //checks to make sure youre not at menustack[0]
      {prevmenuspot=menustack[currentmenuspot-1];} //shifts variable by 1 to before array spot
      
   switch(prevmenuspot) //uses variable and lanuches previous menu
    {
    case 1: 
    MainMenuDisplay();
     break;
    case 2: 
    sensor_menu();
     break;
    case 3:  
    time_menu();
     break;
    case 4: 
    Text();
    }
}

/*00000000000             menu stuff            00000000000000000000000000*/

void findsmenuspot()
{
    for(int c=0; menustack[c]!=0; c++ ) //scans array by starting from beginning and looks for a zero. Zero mean no menu was set and is top of stack
      {currentmenuspot=menustack[c];}   //puts number representing which menu into variable for testing
}


int menuspotmake(int menunumber) //updates array with current menu 
{
    for(int c=0; menustack[c]!=0; c++ ) //scans array by starting from beginning and looks for a zero. Zero mean no menu was set and is top of stack
        {
          menustackspot=c;
        }   //puts number representing which menu into variable for testing
    if(menustack[menustackspot]!=menunumber)
        {
          menustack[menustackspot+1]=menunumber;
        }
}


/*0000000000000000       menus        0000000000000000*/

void BOXSELECTOR()
{
  
     switch(SELECTORSPOT) //based on result opens function that decides what buttons do in that menu
   {case 0:/*The Matrix.*/;
     break;
    case 1:       
                LCD.drawBox(4,53,0,47,0);//x1,y1,x2,y2  draw box on S Sensor
                LCD.drawBox(3,52,1,48,0);
                LCD.drawBox(2,51,2,49,0);
                //delay(50);
                ;
     break;
    case 2:  ;
     break;
    case 3:  ;
     break;}
}

void menu_button_action_reader()//reads the current menu it is in
{

   switch(currentmenuspot) //based on result opens function that decides what buttons do in that menu
   {case 1:  MainMenuButtonAction();
     break;
    case 2:  sensor_menuButtonAction();
     break;
    case 3:  time_menuButtonAction();
     break;
    case 4:  TextButtonAction();
     break;}

}

void MainMenuButtonAction()
{
    if(BUTTONLEFT==true)
        {
          SELECTORSPOT=0;
          //currentmenuspot=2;
          /*action*/;
        }
    else if(BUTTONRIGHT==true)
        {
          SELECTORSPOT=1;
          //currentmenuspot=2;
          /*action*/;
        }
    else if(BUTTONENTER==true)
        {
          //SELECTORSPOT=0;
          //currentmenuspot=3;
          /*action*/;
        }
    else if(BUTTONBACK==true)
        {
          //SELECTORSPOT=0;
          /*action*/;
        }
    else if(BUTTONEXIT==true)
        {
          //SELECTORSPOT=0;
          ;
        }
    else if(BUTTON10==true)
        {
          /*action*/;
        }
}

My program stops and gets stuck in a function and never calls other functions and/maybe never gets back to void loop() I believe my uC menustack gets full and cant get back. When I press a button the sequence of functions are as follows

inside Void loop() is menu_start() -> interrupts void debounce() -> buttontest() -> void debounce() -> menu_button_action_reader() -> MainMenuButtonAction() -> if nest within MainMenuButtonAction()

The if nest has options that checks button pushes where one button puts a blinking box and another option that turns the box off. The program goes through all the functions correctly and turns the box on and then off once and then gets stuck the screen and sensors still work and new info is sent and displayed on the screen but no other button pushes register and the box function stops working. Is the uC menu stack overflowing? is it the if nest or switch case? If my code is too complicated or needs explain please say so. I researched the forum and found that there is no limit to the uC stack is that correct? Did i fill up the RAM?

DO this. Use Serial Monitor in each function call. & print it on serial monitor. Check where serial monitor get stop. If serial monitor stop getting printed that means you have problem after that function call.

I researched the forum and found that there is no limit to the uC stack is that correct? Did i fill up the RAM?

The stack is in RAM if that answers your question.

Your interrupt calls "time_menuButtonAction" but you haven't posted the code for this function.

I recommend you use the auto-format tool to make your code more legible.

int optionspotx=0;
int optionspoty=0;
int enterbutton=0;
int backbutton=0;
int BUTTONLEFT=false;
int BUTTONRIGHT=false;
int BUTTONENTER=false;
int BUTTONBACK=false;
int BUTTONEXIT=false;
int BUTTON10=false;
int menustack[6]={1,0,0,0,0,0}; //array acting as stack for menu porder when hopping from one menu to the other.
int currentmenuspot=1;         // set array size to number of menus desired
int prevmenuspot=1;
int menustackspot=0;
int menunumber;

Using inappropriate datatypes is a good way of wasting RAM.

Thank you everyone for responses, I didn't expect so many responses so quickly.

time_menuButtonAction() right now a empty function that will fill later once i get the menu code to work. Here is the function. Thanks again.

I will also try using the serial monitor to see if i can track where the program gets stuck. Thanks again.

void time_menuButtonAction()
{

    if(BUTTONLEFT==true)
        {/*action*/;}
    else if(BUTTONRIGHT==true)
        {/*action*/;}
    else if(BUTTONENTER==true)
        {/*action*/;}
    else if(BUTTONBACK==true)
        {/*action*/;}
    else if(BUTTONEXIT==true)
        {/*action*/;}
    else if(BUTTON10==true)
        {/*action*/;}
  
}

Apart from initially, when does BUTTONLEFT ever become false?

Also, names in all caps are, by convention, used for constants, and thus we don't expect them to change.

You're right I forget to set them false after it checks them. I'm going to add that and see if that fixes it.

Thanks all for the replies and continued help/
I added a section to make all the BUTTONLEFT and BUTTONRIGHT etc false after they are read, but it didnt solve the problem. I tried putting serial.print and printing text as each function is called. The serial print doesn't work inside void MainMenuButtonAction() it locks the function up and putting it inside void debounce locks the system up when i call mainmenudisplay or MainMenuButtonAction.

The serial print shows the order of the code as follows

void loop
SensorUpdate
menustart
mainmenudisplay
boxselector

then it repeats. It continues to repeat even after i try pressing the button that activates the indicator on the screen in box selector.
Here the code that i changed (page 1)

//v5 clone modified with interrupts

/*00000000      Libraries included    00000000*/
#include <SerialGraphicLCD.h>
#include <SoftwareSerial.h>
#include "DHT.h"
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP183.h>
#include <DS3234.h>

/*00000000      GLCD screen size  00000000*/
#define maxX 127//159 
#define maxY 63 //127

/*00000000   BMPsensor  00000000*/
#define BMP183_CLK  13  // AKA CLK
#define BMP183_SDO  12  // AKA MISO
#define BMP183_SDI  11  // AKA MOSI
#define BMP183_CS   4
Adafruit_BMP183 bmp = Adafruit_BMP183(BMP183_CLK, BMP183_SDO, BMP183_SDI, BMP183_CS);
volatile float pressure_mmHg;
volatile float pressurepascal;
volatile float Altitude;
float last_microsBMP;

/*00000000   DeadOn time chip  00000000*/
volatile int TimeDate [7]; //second,minute,hour,null,day,month,year
const int CSpin=10;
const int MOSIpin=11;
const int MISOpin=12;
const int CLKpin=13;
float last_microsTime;
/*00000000    DHT sensor stuff    00000000*/
#define DHTPIN 9     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE);
volatile float humidity=0;
volatile float airtemp=0;
volatile float heatindex=0;
volatile float last_microsDHT;

/*00000000      variables for PINS    00000000*/
//Bup Bdown Bleft Bright Bcenter But1 But2 But3
//const int ledPin13 = 13;       // the number of the LED pin

/*00000000    variables for debounce    00000000*/
long debouncing_time = 250; //Debouncing delay coefficent
long last_micros;
int state = LOW;

/*00000000    variables for menus    00000000*/
int optionspotx=0;
int optionspoty=0;
int enterbutton=0;
int backbutton=0;
int BUTTONLEFT=false;
int BUTTONRIGHT=false;
int BUTTONENTER=false;
int BUTTONBACK=false;
int BUTTONEXIT=false;
int BUTTON10=false;
int menustack[6]={1,0,0,0,0,0}; //array acting as stack for menu porder when hopping from one menu to the other.
int currentmenuspot=1;         // set array size to number of menus desired
int prevmenuspot=1;
int menustackspot=0;
int menunumber;
volatile long BUTTON_micros=0;
int SELECTORSPOT=0;

/*00000000    LCD class declaration    00000000*/
LCD LCD;

/*00000000    CoSensor declaration    00000000*/
volatile int CoCode;
volatile int CoLevel;
float last_microsCO;
/*00000000    SETUP    00000000*/

void setup()
{
  pinMode(5, INPUT_PULLUP);     //button on pin 5
  pinMode(6, INPUT_PULLUP);
  pinMode(7, INPUT_PULLUP);
  pinMode(8, INPUT_PULLUP);
  
  Serial.begin(9600);
  
  attachInterrupt(0, debounce, FALLING); //interrupt
  
//  pinMode(ledPin13, OUTPUT);   // pin 13 on board LED

  RTC.configure(MOSIpin,MISOpin,CLKpin,CSpin);
//  RTC.setDateTime(12,8,2014,23,25,0); // RTC.setDateTime(int d, int mo, int y, int h, int mi, int s);
  dht.begin();
  bmp.begin();

//RTC.setDateTime(24, 10, 2014, 23, 17, 0); // int d, int mo, int y, int h, int mi, int s

  //splash screen
  LCD.setBacklight(20);
  LCD.clearScreen();
  LCD.setHome();
  LCD.printStr(" Program starts in "); //displays "program is starting in 5/4/3/2/1 etc"
    for(int i = 5; i >= 0; i--) 
      {
        LCD.setX(113);
        LCD.setY(0);
        LCD.printNum(i);
        delay(500);
      } 
  LCD.clearScreen(); 
  delay(200);
}

/*00000000    LOOP    00000000*/

void loop()
{ 
Serial.print("\n");   
Serial.print("voidloop");
Serial.print("\n"); 
delay(50);
SensorUpdate();     //update all sensors including time
menu_start();
BOXSELECTOR();
//MainMenuDisplay();
//menu_select();
//sensor_menu();
//time_menu();

}

void SensorUpdate()
{
Serial.print("SensorUpdate");
Serial.print("\n"); 
delay(50);
  Battery();
  delay(100);
  ClockRead();
  delay(100);
  DHTsensor();
  delay(100);
  CoSensor();
  delay(100);
  BMPsensor();
  delay(100);
}

/*00000000   debounce functions    00000000*/

void debounce() 
{
  /*
Serial.print("debounce");
Serial.print("\n"); 
delay(50);
  */
  if(((long)(micros() - last_micros) >= debouncing_time * 2000) || last_micros==0)
  {
    state = !state;
    //digitalWrite(13, state);
    last_micros = micros();
    buttontest();
    menu_button_action_reader();
    
  }
}

void buttontest()
{
    if(digitalRead(5)==LOW)
    {BUTTONLEFT=true;}
    
    if(digitalRead(6)==LOW)
    {BUTTONRIGHT=true;}
    
    if(digitalRead(7)==LOW)
    {BUTTONENTER=true;}
    
    if(digitalRead(8)==LOW)
    {BUTTONBACK=true;}    
    
    if(digitalRead(9)==LOW)
    {BUTTONEXIT=true;}    
    
    if(digitalRead(10)==LOW)
    {BUTTON10=true;}    
}

void buttonreseter()
{
    BUTTONLEFT==false;
    BUTTONRIGHT==false;
    BUTTONENTER==false;
    BUTTONBACK==false;
    BUTTONEXIT==false;
    BUTTON10==false;
}

void CoSensor()
{
  if((long)micros() - last_microsCO >= 100000 || last_microsCO==0) // Wait a few seconds between measurements. //delay(1000);
  {
  CoLevel = analogRead(A5);// 10k resistor noramlizes in basement at 70
  
  if(CoLevel<300)
    {CoCode=1;}
  else if(CoLevel>301 && CoLevel<800)
    {CoCode=2;}
  else if(CoLevel>801)
    {CoCode=3;}
  }
last_microsCO=micros();  
}

void Battery()
{
}

void ClockRead()
{
RTC.readDateTime(); //DD.MM.YYYY-hh.mm.ss
/*
RTC.time_h(); // hour
RTC.time_m(); // minutes
RTC.time_s(); // seconds
RTC.date_d(); // day
RTC.date_m(); // month
RTC.date_y(); // year
RTC.readTemp();
RTC.setDateTime(int d, int mo, int y, int h, int mi, int s);
*/
TimeDate[2]=RTC.time_h(); //2.1.0 hour minute second
TimeDate[1]=RTC.time_m();
TimeDate[0]=RTC.time_s();
TimeDate[5]=RTC.date_d(); // day
TimeDate[4]=RTC.date_m(); // month
TimeDate[3]=RTC.date_y()-2000; // year
}
  

/*0000000000000000000      BMPsensor     00000000000000000000000000000*/

void BMPsensor() 
{
 if((long)micros() - last_microsBMP >= 100500 || last_microsBMP==0) // Wait a few seconds between measurements. //delay(2050);
 {
    /* Display atmospheric pressue in Pascals */
    //float pressurepascal;
    //float pressure_mmHg;
    pressurepascal=bmp.getPressure();
    pressure_mmHg=pressurepascal*(0.0002953);

    // Pressure bmp.getPressure() Pascals
    // Pressure (bmp.getPressure() / 100) millibar (hPa)
    // Pressure (pressure_mmHg); millimeter Mercury (mmHg)
    
    /* First we get the current temperature from the BMP085 */
    float temperatureF;
    float temperatureC;
    temperatureC =bmp.getTemperature();
    temperatureF=(temperatureC*(1.8))+32; //    F = C * 180 + 32

    float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA; // should be ~1000
    seaLevelPressure=1011;
    //SENSORS_PRESSURE_SEALEVELHPA millibar/hPa
    Altitude=bmp.getAltitude(seaLevelPressure); // meters
 }
last_microsBMP=micros();
}

/*0000000000000000000      DHTsensor     00000000000000000000000000000*/

void DHTsensor() 
{
  if((long)micros() - last_microsDHT >= 100100 || last_microsDHT==0) // Wait a few seconds between measurements. //delay(2100);
      {
      // Reading temperature or humidity takes about 250 milliseconds!
      // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
      float h = dht.readHumidity();
      humidity=dht.readHumidity();
      // Read temperature as Celsius
      float t = dht.readTemperature();
      // Read temperature as Fahrenheit
      float f = dht.readTemperature(true);
      airtemp=dht.readTemperature(true);
      // Check if any reads failed and exit early (to try again).
      if (isnan(h) || isnan(t) || isnan(f)) 
        {
          Serial.println("Failed to read from DHT sensor!");
          //last_micros2=micros();
          return;
        }
      
      // Compute heat index
      // Must send in temp in Fahrenheit!
      float hi = dht.computeHeatIndex(f, h);
      heatindex=dht.computeHeatIndex(f, h);
      }
      last_microsDHT=micros();
}

Here is the other tab of code menu functions. The third tab was unchanged.

void menu_start()
{
Serial.print("menu start");
Serial.print("\n"); 
delay(50);
 findsmenuspot(); //function call to get what current position is. Sends array to check it
 switch(currentmenuspot) //based on result opens the a menu.
   {case 1:  MainMenuDisplay();
     break;
    case 2:  /*sensor_menu()*/;
     break;
    case 3:  /*time_menu()*/;
     break;
    case 4:  /*Text()*/;
     break;
    }
 //BOXSELECTOR();
}

/*0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000   Previous menu function   000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*/
  
  
int prevmenu () //function to find what previous menu is
{
  for(int c=0; menustack[c]!=0; c++ ) //scans from array[0] until it finds a 0
      {
        currentmenuspot=menustack[c-1]; //saves number which is the menu to variable to be tested 
      }    

    if (menustack[currentmenuspot-1] !=1) //checks to make sure youre not at menustack[0]
      {prevmenuspot=menustack[currentmenuspot-1];} //shifts variable by 1 to before array spot
      
   switch(prevmenuspot) //uses variable and lanuches previous menu
    {
    case 1: 
    MainMenuDisplay();
     break;
    case 2: 
    sensor_menu();
     break;
    case 3:  
    time_menu();
     break;
    case 4: 
    Text();
    }
}

/*00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000   menu stuff   0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*/

void findsmenuspot()
{
    for(int c=0; menustack[c]!=0; c++ ) //scans array by starting from beginning and looks for a zero. Zero mean no menu was set and is top of stack
      {currentmenuspot=menustack[c];}   //puts number representing which menu into variable for testing
}


int menuspotmake(int menunumber) //updates array with current menu 
{
    for(int c=0; menustack[c]!=0; c++ ) //scans array by starting from beginning and looks for a zero. Zero mean no menu was set and is top of stack
        {
          menustackspot=c;
        }   //puts number representing which menu into variable for testing
    if(menustack[menustackspot]!=menunumber)
        {
          menustack[menustackspot+1]=menunumber;
        }
}


/*00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000   menus   0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*/

void BOXSELECTOR()
{
  
Serial.print("BOXSELECTOR");
Serial.print("\n"); 
delay(50);
  
     switch(SELECTORSPOT) //based on result opens function that decides what buttons do in that menu
   {case 0:/*The Matrix.*/;
     break;
    case 1:       
                LCD.drawBox(4,53,0,47,0);//x1,y1,x2,y2  draw box on S Sensor
                LCD.drawBox(3,52,1,48,0);
                LCD.drawBox(2,51,2,49,0);
                delay(50);
                ;
     break;
    case 2:  ;
     break;
    case 3:  ;
     break;}
     

}

void menu_button_action_reader()//reads the current pipboy is in
{

   switch(currentmenuspot) //based on result opens function that decides what buttons do in that menu
   {case 1:  MainMenuButtonAction();
     break;
    case 2:  sensor_menuButtonAction();
     break;
    case 3:  time_menuButtonAction();
     break;
    case 4:  TextButtonAction();
     break;}

}

void MainMenuButtonAction()
{

    if(BUTTONLEFT==true)
        {
          SELECTORSPOT=0;
          //currentmenuspot=2;
          /*action*/
        //Serial.print("SELECTORSPOT=0");
        //Serial.print("\n"); 
        //delay(50);
        }
    else if(BUTTONRIGHT==true)
        {
          SELECTORSPOT=1;
          //currentmenuspot=2;
          /*action*/
        //Serial.print("SELECTORSPOT=1");
        //Serial.print("\n"); 
        //delay(50);
        }
    else if(BUTTONENTER==true)
        {
          //SELECTORSPOT=0;
          //currentmenuspot=3;
          /*action*/;
        }
    else if(BUTTONBACK==true)
        {
          //SELECTORSPOT=0;
          /*action*/;
        }
    else if(BUTTONEXIT==true)
        {
          //SELECTORSPOT=0;
          ;
        }
    else if(BUTTON10==true)
        {
          /*action*/;
        }
    
  buttonreseter();
}

void sensor_menuButtonAction()
{
    if(BUTTONLEFT==true)
        {/*action*/;}
    else if(BUTTONRIGHT==true)
        {/*action*/;}
    else if(BUTTONENTER==true)
        {/*action*/;}
    else if(BUTTONBACK==true)
        {/*action*/;}
    else if(BUTTONEXIT==true)
        {/*action*/;}
    else if(BUTTON10==true)
        {/*action*/;} 
        
    buttonreseter();
}

void time_menuButtonAction()
{

    if(BUTTONLEFT==true)
        {/*action*/;}
    else if(BUTTONRIGHT==true)
        {/*action*/;}
    else if(BUTTONENTER==true)
        {/*action*/;}
    else if(BUTTONBACK==true)
        {/*action*/;}
    else if(BUTTONEXIT==true)
        {/*action*/;}
    else if(BUTTON10==true)
        {/*action*/;}
  buttonreseter();
}

void TextButtonAction()
{

    if(BUTTONLEFT==true)
        {/*action*/;}
    else if(BUTTONRIGHT==true)
        {/*action*/;}
    else if(BUTTONENTER==true)
        {/*action*/;}
    else if(BUTTONBACK==true)
        {/*action*/;}
    else if(BUTTONEXIT==true)
        {/*action*/;}
    else if(BUTTON10==true)
        {/*action*/;}

  buttonreseter();
}

void Text(){}

Have you checked how much memory you are using, and how much is available?
http://playground.arduino.cc/Code/AvailableMemory

it says i have 1169 free memory

I inserted serial print data in my code and the function calls without pushing buttons is

void loop
Sensorupdate
menustart
mainmenudisplay
BoxSelector

when a button is pushed the function call is as follows (from visual inspection)

debounce
buttontest
menubuttonactionreader
MainMenuButtonAction

the serial print is suppose to print zero for button 1 and 1 for button two

the serial print prints zero fine but after it prints one once and then back to zero it can never go back to one, the program also starts registers the second button as button one and prints zero

My feeling is that you have allowed the code to get too complex before you ensured that your menu system works properly.

If it was my project I would write a fresh program with nothing in it but the menu code and stubs for the various function (maybe just containing Serial.println("FunctionX"); and get that working properly.

Then I would start adding in the other stuff one section at a time, making sure each piece works before going on to the next.

You are using a lot of libraries and I would not be surprised if there are conflicts or if, between them, they are using too much SRAM.

...R

it says i have 1169 free memory

If that is 1169 of 8196 on a Mega, then you have enough memory. If that is 1160 of 2048 on a Uno or other 328 based Arduino, it is wrong, and you are out of memory.

Its on the Sparkfun's red board which is clone of the Uno. So i need to make my code smaller i.e. define variables, and do less things in the code then?

void buttonreseter()
{
    BUTTONLEFT==false;
    BUTTONRIGHT==false;
    BUTTONENTER==false;
    BUTTONBACK==false;
    BUTTONEXIT==false;
    BUTTON10==false;
}