Help!!! My Code is only running only part of my Loop

Hello Friends,i have been helping a friend to develop a code, i have in the loop
menuPrincipal()

since is a simulating device for my airsoft games, i wanted to put some fading lights, but i added to the code and only get the menuPrincipal() part only working. if i delete that and leave the rest then i get he fading lights. heres my code to see if you guys can help, and sry fr my poor knowledge, since my friend developed the code but this small thing its making us crazy.

#include <Wire.h> 
#include <Keypad.h>
//#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal.h>
/*|
 Arduino Bomb Pro
 
 The circuit:
 * More info at : http://yin.mainstreamds.com/
 If you need some help mail me to yinbot@gmail.com
 
 created 4,Sep, 2010
 Modified 27 june 2013
 by Ignacio Lillo
 
 */

//LiquidCrystal_I2C lcd(0x38,16,2);
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
  {
    '1','2','3','a'                      }
  ,
  {
    '4','5','6','b'                      }
  ,
  {
    '7','8','9','c'                      }
  ,
  {
    '*','0','#','d'                      }
};

byte rowPins[ROWS] = {
  A4, A5, 13, 12}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {
  A0, A1, A2, A3
}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );


char enteredText[8];
char password[8];
int key=-1;
char lastKey;
char var;
boolean passwordEnable=false;

//Buttons for lcd shield
char BT_RIGHT = '4';
char BT_UP = 'a';
char BT_DOWN = 'b';
char BT_LEFT = '6';
char BT_SEL = 'd';   // Ok key  
char BT_DEFUSER = 'x';   // not implemented

//leds
int led = 9;           // the pin that the LED is attached to
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;
const int REDLED = 11;
const int GREENLED = 10;
//const int BLUELED = 12;
//mosfet
boolean mosfetEnable = false;
const int mosfet = 1;
//IS VERY IMPORTANT THAT YOU TEST THIS TIME. BY DEFAULT IS IN 1 SEC. THAT IS NOT TOO MUCH. SO TEST IT!
const int MOSFET_TIME = 5000;

//TIME INTS
int GAMEHOURS = 0;
int GAMEMINUTES = 15;
int BOMBMINUTES = 4;
int ACTIVATESECONDS = 5;

boolean endGame = false;

boolean sdStatus = false; //search and destroy game enable used in config
boolean saStatus = false; //same but SAbotaghe
boolean doStatus = false; //for DEmolition
boolean start = true;
// SOUND TONES
boolean soundEnable = true;
int tonepin = 8; // Pin 8 for the sound
int tonoPitido = 3000;
int tonoAlarma1 = 700;
int tonoAlarma2 = 2600;
int tonoActivada = 1330;
int errorTone = 100;

unsigned long iTime;
unsigned long timeCalcVar;
unsigned long redTime;
unsigned long greenTime;
unsigned long iZoneTime;//initial time for zone
byte team=0; // 0 = neutral, 1 = green team, 2 = red team

void setup(){
  pinMode(led, OUTPUT);
  lcd.begin(16, 2);
//  lcd.init();                      // initialize the lcd 
//  lcd.backlight();
  lcd.setCursor(2,0);
  lcd.print("INITIALIZING");// you can add your team name or someting cool
  lcd.setCursor(0,1);
  lcd.print("BIOCHEMICAL BOMB");// you can add your team name or someting cool
  keypad.setHoldTime(100);
  keypad.setDebounceTime(50);
  delay(2500);
  lcd.clear();
  lcd.setCursor(1,0);
  lcd.print("Be:");// you can add your team name or someting cool
  lcd.setCursor(4,1);
  lcd.print("Prepared");// you can add your team name or someting cool
  keypad.setHoldTime(100);
  keypad.setDebounceTime(50);
  delay(2500);
  pinMode(GREENLED, OUTPUT);     
  pinMode(REDLED, OUTPUT); 
  pinMode(mosfet, OUTPUT);  
  // CONFIGURE THE BARS OF PROGRESS BAR
  byte bar1[8] = {
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
    B10000,
  };
  byte bar2[8] = {
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
    B11000,
  };
  byte bar3[8] = {
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
    B11100,
  };
  byte bar4[8] = {
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
    B11110,
  };
  byte bar5[8] = {
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
    B11111,
  };
  byte up[8] = {
    B00000,
    B00100,
    B01110,
    B11111,
    B11111,
    B00000,
    B00000,
  };

  byte down[8] = {
    B00000,
    B00000,
    B11111,
    B11111,
    B01110,
    B00100,
    B00000,
  };
  lcd.createChar(0,bar1);
  lcd.createChar(1,bar2);
  lcd.createChar(2,bar3);
  lcd.createChar(3,bar4);
  lcd.createChar(4,bar5);
  lcd.createChar(5,up);
  lcd.createChar(6,down);
}


void loop(){
  menuPrincipal();
  analogWrite(led, brightness);    
  brightness = brightness + fadeAmount; 
  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ; 
  }       
  delay(30);
  menuPrincipal();
}


void disarmedSplash(){

  if(sdStatus || saStatus){
    cls();
    lcd.print("  BOMB DISARMED");
    lcd.setCursor(0,1);
    lcd.print("   GOODS WIN");
    digitalWrite(GREENLED, HIGH);  
    delay(5000);
    digitalWrite(GREENLED, LOW); 
  }
  //end code
  cls();
  lcd.print("Play Again?");
  lcd.setCursor(0,1);
  lcd.print("A : Yes B : No");
  while(1)
  {
    var = keypad.waitForKey();
    if(var == 'a' ){
      tone(tonepin,2400,30);
      search();
      break;
    }  
    if(var == 'b' ){
      tone(tonepin,2400,30);
      menuPrincipal();
      break;
    }  
  } 
}

void explodeSplash(){

  cls();
  delay(100);
  lcd.print(" TERRORISTS WIN");
  lcd.setCursor(0,1);
  lcd.print("   GAME OVER");
  for(int i = 200; i>0; i--)// this is the ultra hi definition explosion sound xD
  {
    tone(tonepin,i);
    delay(20);
  }
  noTone(tonepin);

  if(mosfetEnable){
    activateMosfet(); 
  }
  delay(5000);
  cls();

  //end code
  lcd.print("Play Again?");
  lcd.setCursor(0,1);
  lcd.print("A : Yes B : No");
  while(1)
  {
    var = keypad.waitForKey();
    if(var == 'a' ){
      tone(tonepin,2400,30);
      //We have two options, search & destroy and sabotaje play again options so!
      if(sdStatus){
        startGameCount();
        search();
      }
      if(saStatus){
        saStatus=true;
        startGameCount();
        start=true; //to set iTime to actual millis() :D
        sabotage();
      }
    }  
    if(var == 'b' ){
      tone(tonepin,2400,30);
      menuPrincipal();
      break;
    }  
  } 
}

There doesn't appear to be a function for menuPrinciple, and if there is one, where is it located? You don't appear to be calling any other libraries.

they are in the same folder, i open bombpro.ino and it opens all the tabs in the IDE. but it is working fawlessly until i decided to add the faded tutorial to the loop so i can have that LED fading. thats where it only runs the menuPrincipal() and if i delete that then the fading part works :frowning: Again sry for my poor knowledge since iam starting to get the hang of it... and thank for your reply :slight_smile:

by the way this is the code for menuPrincipal.ino

//##################MENUS###############################

void menuPrincipal(){   //MAIN MENU

  digitalWrite(GREENLED, LOW); 
 digitalWrite(REDLED, LOW); 
  //Draw menu
  cls();//clear lcd and set cursor to 0,0
  int i=0;
  char* menu1[]={
    "Search&Destroy","Sabotage","Domination", "Bomb Setup"        }; // HERE YOU CAN ADD MORE ITEMS ON THE MAIN MENU
  lcd.print(menu1[i]);
  lcd.setCursor(15,1);
  checkArrows(i,2);
  while(1){

    var = keypad.waitForKey();
    if(var == BT_UP && i>0){
      tone(tonepin,2400,30);
      i--;
      cls();
      lcd.print(menu1[i]);
      checkArrows(i,3);
      delay(100);
    }
    if(var == BT_DOWN && i<3){
      tone(tonepin,2400,30);
      i++;
      cls(); 
      lcd.print(menu1[i]);    
      checkArrows(i,3);
      delay(100);

    }

    if(var == BT_SEL){
      tone(tonepin,2400,30);
      cls();
      switch (i){

      case 0:
        sdStatus=true;
        configQuickGame();
        startGameCount();
        search();
        break;
      case 1: 
        saStatus=true;
        configQuickGame();
        startGameCount();
        sabotage();
        break;
      case 2:
            
        doStatus=true;
        configQuickGame();
        startGameCount();
        domination();
        break;
      case 3:
        config();
        break;

      }
    }
  }
}

void config(){
  //Draw menu
  lcd.clear();
  lcd.setCursor(0, 0);
  int i=0;
  char* menu2[]={
    "Game Config","Sound Config", "Mosfet Test", "Exit", "Auto Test",            }; // HERE YOU CAN ADD MORE ITEMS ON THE MENU
  delay(500);
  lcd.print(menu2[i]);
  checkArrows(i,3);

  while(1){
    var=keypad.waitForKey();
    if(var == BT_UP && i>0){
      tone(tonepin,2400,30);
      i--;
      lcd.clear();  
      lcd.print(menu2[i]);
      checkArrows(i,3);
      delay(200);

    }
    if(var == BT_DOWN && i<4){
      tone(tonepin,2400,30);
      i++;
      lcd.clear();  
      lcd.print(menu2[i]);
      checkArrows(i,3);
      delay(200);
    }

    if(var == BT_SEL){
      tone(tonepin,2400,30);
      lcd.clear();
      switch (i){

      case 0:
        //gameConfigMenu();
        break;

      case 1:
        //soundConfigMenu();
        break;

      case 2:
        cls();
        lcd.print("Mosfet ON!");
        digitalWrite(mosfet, HIGH);   // turn the LED on (HIGH is the voltage level)
        delay(4000);   // wait for 4 second
        cls();
        lcd.print("Mosfet OFF!");
        digitalWrite(mosfet, LOW);
        delay(2000);
        config();
        break;
      
      case 4:
        //AutoTestMenu();
        break;
        
      case 3:
       cls();
       lcd.print("Exiting!");
       delay(1000);
       menuPrincipal();
       break; 
      }
    }
  }
}

void configQuickGame(){

  cls();
  //GAME TIME
  if(sdStatus || doStatus || saStatus){
    lcd.print("Game Time:");
    lcd.setCursor(0,1);
    checkArrows(1,2);
    delay(800);
    while(!isPressed(BT_SEL)){

      lcd.setCursor(0,1);  
      lcd.print(GAMEMINUTES);  
      lcd.print("   minutes");

      if(isPressed('a') && GAMEMINUTES<180){
        tone(tonepin,2400,30);
        GAMEMINUTES++;
        delay(200);
      }
      if(isPressed('b') && GAMEMINUTES>1){
        tone(tonepin,2400,30);
        GAMEMINUTES--;
        delay(200);
      }
    }
    tone(tonepin,2400,30);
    cls();
  }
  //BOMB TIME
  if(sdStatus || saStatus){
    lcd.print("Bomb Time:");
    lcd.setCursor(0,1);
    checkArrows(1,2);
    delay(800);

    while(!isPressed(BT_SEL)){
      lcd.setCursor(0,1);  
      lcd.print(BOMBMINUTES);  
      lcd.print(" minutes");

      if(isPressed('b') && BOMBMINUTES>1){
        tone(tonepin,2400,30);
        BOMBMINUTES--;
        delay(200);
      }
      if(isPressed('a') && BOMBMINUTES<20){
        tone(tonepin,2400,30);
        BOMBMINUTES++;
        delay(200);
      }
    }
    tone(tonepin,2400,30);
  }
  cls();
  //ARMING TIME
  if(sdStatus || doStatus || saStatus){
    lcd.print("Arm time:");
    lcd.setCursor(0,1);
    checkArrows(1,2);
    delay(800);

    while(!isPressed(BT_SEL)){
      lcd.setCursor(0,1);  
      lcd.print(ACTIVATESECONDS);  
      lcd.print(" seconds");

      if(isPressed('b') && ACTIVATESECONDS>5){
        tone(tonepin,2400,30);
        ACTIVATESECONDS--;
        delay(200);
      }   
      if(isPressed('a') && ACTIVATESECONDS<30){
        ACTIVATESECONDS++;
        tone(tonepin,2400,30);
        delay(200);
      }
    }
    tone(tonepin,2400,30);
    ACTIVATESECONDS-=1; // Just a fix

  }
  //Want sound??
  if(sdStatus || saStatus || doStatus){
  cls();
  lcd.print("Enable Sound?");
  lcd.setCursor(0,1);
  lcd.print("A : Yes B : No");

  while(1)
  {
    var = keypad.waitForKey();
    if(var == 'a' ){
      soundEnable=true;
      tone(tonepin,2400,30);
      break;
    }  

    if(var == 'b' ){
      soundEnable=false;
      tone(tonepin,2400,30);
      break;
    }  
  }
} 
  //Activate Mosfet at Terrorist game ends??? Boom!

  if(sdStatus || saStatus){
    cls();
    lcd.print("Enable Mosfet?");
    lcd.setCursor(0,1);
    lcd.print("A : Yes B : No");
    while(1)
    {
      var = keypad.waitForKey();
      if(var == 'a' ){
        mosfetEnable=true;
        tone(tonepin,2400,30);
        break;
      }  
      if(var == 'b' ){
        mosfetEnable=false;
        tone(tonepin,2400,30);
        break;
      }  
    } 
  }
  //You Want a password enable-disable game?
  if(sdStatus || saStatus){
    cls();
    lcd.print("Enable Code Arm?");
    lcd.setCursor(0,1);
    lcd.print("A : Yes B : No");

    while(1)
    {
      var = keypad.waitForKey();
      if(var == 'a' ){
        tone(tonepin,2400,30);
        setNewPass();
        passwordEnable = true;
        break;
      }  
      if(var == 'b' ){
        tone(tonepin,2400,30);
        passwordEnable = false;
        break;
      }  
    } 
    tone(tonepin,2400,30);
  }  
  //Continue the game :D
}

So menuPrinciple is an entirely different sketch? Why not copy and paste the functions from "menuPrincipal.ino" and put them at the end of the sketch your working on now. The compiler is not going to use a function if it does not know where it is.

they are actually 7 different sketches, one for the menu, one for every type of game, one for the keys, ect. but since he made it that way and i was learning i thought that was how u do it :S

First, you need to make sure they are all in the same sketch folder and then you need to include those sketches with #include<xxxx.ino> at the top of your code.

Done and still dont get the loop to work both parts the fade and calling the menu :~

I see that your menuPrinciple function has a while(1) loop in it, what in that function breaks out of that loop? Its not the "breaks" inside the switch function, those are just for the switch function. So what make the menuPrinciple break out of that while loop?

i think it breaks out when u make a selection in the keypad. i was thinking and should i be able to load the menuPrincipal() without been inside the loop????

skdragon:
i think it breaks out when u make a selection in the keypad. i was thinking and should i be able to load the menuPrincipal() without been inside the loop????

There's certainly nothing in the code that tells it to break out of the while(1) loop. The code is just going to keep going round and round stuck there until it gets told to leave. What line of code do you think is getting you out of it? Maybe while(1) isn't the best choice. Maybe have the while loop check to see if a valid choice has been made instead.

HazardsMind:
and then you need to include those sketches with #include<xxxx.ino> at the top of your code.

No you don't! All .ino files in a sketch folder are automatically combined into a single .cpp file before compiling. It is one of the many awful ways that the Arduino IDE screws around with the normal build process.

Delta_G nailed the problem, you have this inside your menuPrincipal() function:

 while(1){
     ...
  }

And there is nothing to break out of it. That means menuPrincipal() will never ever ever return. So loop() will never continue past that function.

I was unaware that just having the sketches in the same folder would work, I never tested to see if it would still work without calling the sketch itself. But now I know, thanks.

Actually I nailed the problem before Delta_G, I just didn't want to give skydragon a direct answer, I wanted him to think about it.

i am starting to study how all this work and theres a lot i dont get yet, can someone please teach me then how to change the While(1) problem so i can have both procedures runing. i just want the fading light working all the time arduino is on and being able to run the menu =(

Here, this should work. Just copy and paste the entire sketch with this one.

void menuPrincipal(){   //MAIN MENU

  digitalWrite(GREENLED, LOW); 
 digitalWrite(REDLED, LOW); 
  //Draw menu
  cls();//clear lcd and set cursor to 0,0
  int i=0;
  char* menu1[]={
    "Search&Destroy","Sabotage","Domination", "Bomb Setup"        }; // HERE YOU CAN ADD MORE ITEMS ON THE MAIN MENU
  lcd.print(menu1[i]);
  lcd.setCursor(15,1);
  checkArrows(i,2);
  while(1){

    var = keypad.waitForKey();
    if(var == BT_UP && i>0){
      tone(tonepin,2400,30);
      i--;
      cls();
      lcd.print(menu1[i]);
      checkArrows(i,3);
      break; // ADDED
    }
    if(var == BT_DOWN && i<3){
      tone(tonepin,2400,30);
      i++;
      cls(); 
      lcd.print(menu1[i]);    
      checkArrows(i,3);
      break;// ADDED
    }

    if(var == BT_SEL){
      tone(tonepin,2400,30);
      cls();
      switch (i){

      case 0:
        sdStatus=true;
        configQuickGame();
        startGameCount();
        search();
        break;
      case 1: 
        saStatus=true;
        configQuickGame();
        startGameCount();
        sabotage();
        break;
      case 2:
            
        doStatus=true;
        configQuickGame();
        startGameCount();
        domination();
        break;
      case 3:
        config();
        break;

      }
      break;// ADDED
    }
  }
}

void config(){
  //Draw menu
  lcd.clear();
  lcd.setCursor(0, 0);
  int i=0;
  char* menu2[]={
    "Game Config","Sound Config", "Mosfet Test", "Exit", "Auto Test",            }; // HERE YOU CAN ADD MORE ITEMS ON THE MENU
  delay(500);
  lcd.print(menu2[i]);
  checkArrows(i,3);

  while(1){
    var=keypad.waitForKey();
    if(var == BT_UP && i>0){
      tone(tonepin,2400,30);
      i--;
      lcd.clear();  
      lcd.print(menu2[i]);
      checkArrows(i,3);
      break; // ADDED
    }
    if(var == BT_DOWN && i<4){
      tone(tonepin,2400,30);
      i++;
      lcd.clear();  
      lcd.print(menu2[i]);
      checkArrows(i,3);
      break;// ADDED
    }

    if(var == BT_SEL){
      tone(tonepin,2400,30);
      lcd.clear();
      switch (i){

      case 0:
        //gameConfigMenu();
        break;

      case 1:
        //soundConfigMenu();
        break;

      case 2:
        cls();
        lcd.print("Mosfet ON!");
        digitalWrite(mosfet, HIGH);   // turn the LED on (HIGH is the voltage level)
        delay(4000);   // wait for 4 second
        cls();
        lcd.print("Mosfet OFF!");
        digitalWrite(mosfet, LOW);
        delay(2000);
        config();
        break;
      
      case 4:
        //AutoTestMenu();
        break;
        
      case 3:
       cls();
       lcd.print("Exiting!");
       delay(1000);
       menuPrincipal();
       break; 
      }
      break; // ADDED
    }
  }
}

void configQuickGame(){

  cls();
  //GAME TIME
  if(sdStatus || doStatus || saStatus){
    lcd.print("Game Time:");
    lcd.setCursor(0,1);
    checkArrows(1,2);
    delay(800);
    while(!isPressed(BT_SEL)){

      lcd.setCursor(0,1);  
      lcd.print(GAMEMINUTES);  
      lcd.print("   minutes");

      if(isPressed('a') && GAMEMINUTES<180){
        tone(tonepin,2400,30);
        GAMEMINUTES++;
        delay(200);
      }
      if(isPressed('b') && GAMEMINUTES>1){
        tone(tonepin,2400,30);
        GAMEMINUTES--;
        delay(200);
      }
    }
    tone(tonepin,2400,30);
    cls();
  }
  //BOMB TIME
  if(sdStatus || saStatus){
    lcd.print("Bomb Time:");
    lcd.setCursor(0,1);
    checkArrows(1,2);
    delay(800);

    while(!isPressed(BT_SEL)){
      lcd.setCursor(0,1);  
      lcd.print(BOMBMINUTES);  
      lcd.print(" minutes");

      if(isPressed('b') && BOMBMINUTES>1){
        tone(tonepin,2400,30);
        BOMBMINUTES--;
        delay(200);
      }
      if(isPressed('a') && BOMBMINUTES<20){
        tone(tonepin,2400,30);
        BOMBMINUTES++;
        delay(200);
      }
    }
    tone(tonepin,2400,30);
  }
  cls();
  //ARMING TIME
  if(sdStatus || doStatus || saStatus){
    lcd.print("Arm time:");
    lcd.setCursor(0,1);
    checkArrows(1,2);
    delay(800);

    while(!isPressed(BT_SEL)){
      lcd.setCursor(0,1);  
      lcd.print(ACTIVATESECONDS);  
      lcd.print(" seconds");

      if(isPressed('b') && ACTIVATESECONDS>5){
        tone(tonepin,2400,30);
        ACTIVATESECONDS--;
        delay(200);
      }   
      if(isPressed('a') && ACTIVATESECONDS<30){
        ACTIVATESECONDS++;
        tone(tonepin,2400,30);
        delay(200);
      }
    }
    tone(tonepin,2400,30);
    ACTIVATESECONDS-=1; // Just a fix

  }
  //Want sound??
  if(sdStatus || saStatus || doStatus){
  cls();
  lcd.print("Enable Sound?");
  lcd.setCursor(0,1);
  lcd.print("A : Yes B : No");

  while(1)
  {
    var = keypad.waitForKey();
    if(var == 'a' ){
      soundEnable=true;
      tone(tonepin,2400,30);
      break;
    }  

    if(var == 'b' ){
      soundEnable=false;
      tone(tonepin,2400,30);
      break;
    }  
  }
} 
  //Activate Mosfet at Terrorist game ends??? Boom!

  if(sdStatus || saStatus){
    cls();
    lcd.print("Enable Mosfet?");
    lcd.setCursor(0,1);
    lcd.print("A : Yes B : No");
    while(1)
    {
      var = keypad.waitForKey();
      if(var == 'a' ){
        mosfetEnable=true;
        tone(tonepin,2400,30);
        break;
      }  
      if(var == 'b' ){
        mosfetEnable=false;
        tone(tonepin,2400,30);
        break;
      }  
    } 
  }
  //You Want a password enable-disable game?
  if(sdStatus || saStatus){
    cls();
    lcd.print("Enable Code Arm?");
    lcd.setCursor(0,1);
    lcd.print("A : Yes B : No");

    while(1)
    {
      var = keypad.waitForKey();
      if(var == 'a' ){
        tone(tonepin,2400,30);
        setNewPass();
        passwordEnable = true;
        break;
      }  
      if(var == 'b' ){
        tone(tonepin,2400,30);
        passwordEnable = false;
        break;
      }  
    } 
    tone(tonepin,2400,30);
  }  
  //Continue the game :D
}
 
 
 Report to moderator    Logged

hello Friends: Just got home from work and tried out the added break on the menu,but when it come up it doesnt let me choose the type of game: it keeps saying search and destroy even if i press up or down and the led keeps light on with out fading. someone pm me and told me it was better with just using a 555 timer and keeping the code how it is. it really got me sad since i though anything was possible in arduino. but it seems that iam gettign stuck at menu until a selection is made not making posible the fading to start. What got me thinking if i cant do it from the momment i start the arduino....

Can i do the light fading effect inside every type of game??? imean if i select search and destroy when the games beggins then start fading the light on and off. can b possible that way??? iam just looking at different outcomes and possibl solutions. Thanks for all of you helping a friend out. Att: Ettiene

Ok, see what happens when you take out the very last "break" in menuPrinciple.

This is quite difficult to debug without actually seeing the outcomes.

try it too, same prob. i know its mega hard when not able to trial and error, i think i will just stick to the 555 timer, thanks fpr the support guys, other thing i thought was incorporating my arduino micro.