LCD MENU PROBLEMS

Hello guys. :grin:

For graduation I need to do one product. I started programing it but I have problems and professor does not want to help me because he is idiot :smiling_imp: so i am asking you to help me

I am doing machine for drinks. There will be 5 drinks and 5 pumps. You will choose how many % of particular drink you want and machine will pump it for you haha something like that.
I will have lcd and 4 buttons for controling but there comes problem because I am not good at programming beacuse that professor didn't teach us nothing.

I started coding it in "my way" hahaha but I have problems now so I am asking you to help.
You can found my program later and I wrote some comments that you will know what I am thinking with my stupid logic haha. ;D

Actually this voids are doing good but the problem is when calling the next function.
"size_glass" is OK and everything work as I want and when I click button "forward" it goes to "choose_way" as it supposed to.
Then when i click buttons "plus" or "minus" cursor move as it should
but the problem is if I have Cursor on "MIX YOURSELF" and click button "forward" the program do not call "drink_1" but instead of that caling "drink_5" so arduino skiping pages.

I realy don't know what to do and I don't have nobody to ask so I am asking you.
I will be very grateful if you can help.

Sorry for poor english and thank for all comments and help :kissing:

P.S. I need to post code in comments beacuse there is not enough space

#include <LiquidCrystal.h>
LiquidCrystal lcd(3, 4, 5, 6, 7, 8);
int a =1;
int b =0;
int c =0;
int d =0;
int e =0;
int f =0;
int i =0;
int x =0;
int p =100;     //that "p" is because I want that you can't have all procents together more than 100% that is more realistic but I haven't done that yet :(
int back =9;   //there you can see in which pins i have connected buttons
int minus =10;
int plus =11;
int forward =12;

void setup() 
{
  lcd.begin(16, 2);
  pinMode(back,INPUT);
  pinMode(plus,INPUT);
  pinMode(minus,INPUT);
  pinMode(forward,INPUT);
}

void loop()
{
  
   if (x == 0) 
    {
        size_glass();
    }  

  if (x == 1) 
    {
        choose_way();
    }

  if (x == 2) 
    {
        drink_1();
    }  

  if (x == 3) 
    {
        drink_2();
    }  

  if (x == 4) 
    {
        drink_3();
    }  

  if (x == 5) 
    {
        drink_4();
    }  

  if (x == 6) 
    {
        drink_5();
    }  
}






void size_glass()
{
    lcd.setCursor(0, 0);
    lcd.print("SIZE OF GLASS");
    int plus1 = digitalRead(plus);
    int minus1 = digitalRead(minus);
    int forward1 = digitalRead(forward);
    int back1 = digitalRead(back);
  
    lcd.setCursor(3, 1);
    lcd.print(a);
    lcd.setCursor(5, 1);
    lcd.print("dL");

    if (plus1 == HIGH && a==3)   //with that I just want that it will go from 3 straight to 5 because I don't use 4 dL glasses
    {
        a= a+2;
        lcd.setCursor(3, 1);
        lcd.print(a);
        delay(200);
    }
  
    if (plus1 == HIGH && a<3)   //if you click button plus, "a" will go plus 1 until "a" reach 3
    {
        a= a+1;
        lcd.setCursor(3, 1);
        lcd.print(a);
        delay(200);
    }
  
    if (minus1 == HIGH && a>1 && a<4) //if you click button minus, "a" will go minus 1 until "a" reach 1
    {
        a= a-1;
        lcd.setCursor(3, 1);
        lcd.print(a);
        delay(200);
    }
  
    if (minus1 == HIGH && a==5)   //if you click button minus and "a" is 5 then "a" will go on 3
    {
        a= a-2;
        lcd.setCursor(3, 1);
        lcd.print(a);
        delay(200);
    }
    
    if (forward1 == HIGH)  //if you click button forward "x" will go on 1 and in the void will call "choose_way"
    {
        lcd.clear();
        x=1;
    }    
}





void choose_way()
{
  // this void is a little different because I want that people can choose between 2 options. 
  // If you choose first option then you will be later able to choose drinks that are already made. (procents of drinks already saved in arduino)
  // And if you choose second options you can choose procents of drinks by yourself
  // I just did the second options and the first one I will add later 
    lcd.setCursor(2, 0);
    lcd.print("CHOOSE DRINK");
    lcd.setCursor(2, 1);
    lcd.print("MIX YOURSELF");
    
    int plus2 = digitalRead(plus);
    int minus2 = digitalRead(minus);
    int forward2 = digitalRead(forward);
    int back2 = digitalRead(back);
    
    lcd.setCursor(0, i);  // "i" is already zero so in the top left corner lcd will print ">"
    lcd.print(">");
    delay (100);

    if (plus2 == HIGH)  // if you click plus botton then ">" from first row wil be deleted and moved to second row
    {
        lcd.setCursor(0, i);
        lcd.print(" ");
        i=1;
        lcd.setCursor(0, i); 
        lcd.print(">");
        delay (10);
    }
    
    if (minus2 == HIGH)   // if you click minus botton then ">" from second row wil be deleted and moved to first row
    {
        lcd.setCursor(0, i); 
        lcd.print(" ");
        i=0;
        lcd.setCursor(0, i); 
        lcd.print(">");
        delay (10);
    }

    if (forward2 == HIGH && i==0)  // if you click forward button and "i" is 0 then you choose the first option and arduino will go to already made drinks (i haven't done that yet)
    {
      
    }  

    if (forward2 == HIGH && i==1)   // if you click forward button and "i" is 1 then you choose the second option and "x" will go on 2 and in the void will call "drink_1"
    {
        lcd.clear();
        x=2;
    }
    

    if (back2 == HIGH)  //if you click button back "x" will go on 0 and in the void will call "size_glass" again
    {
        lcd.clear();
        x=0;
    }
}






void drink_1() 
{
  //there is void for drink one, so you choose how many procents of drink one do you want and then click forward button
    lcd.setCursor(0, 0);
    lcd.print("DRINK 1:");
    int plus3 = digitalRead(plus);
    int minus3 = digitalRead(minus);
    int forward3 = digitalRead(forward);
    int back3 = digitalRead(back);
  
    lcd.setCursor(3, 1);
    lcd.print(b);
    
    
  
    if (plus3 == HIGH && b<100)   //if you click button plus "b" will go plus 10 until it reach 100, because I think that 10 % precicion is enought
    {                             // lcd then print b
        b= b+10;
        lcd.setCursor(3, 1);
        lcd.print(b);
        delay(200);
    }
  
    if (minus3 == HIGH && b>0)   //minus is same as plus but "b" go minus 10
    {
        b= b-10;
        lcd.setCursor(3, 1);
        lcd.print(b);
        delay(200);
    }

    if (b<100)                  //if "b" is lesss then 100 then clear Cursor(6, 1) and write "%" on Cursor(5, 1)
    {
        lcd.setCursor(6, 1);
        lcd.print(" ");         //I need to clear Cursor(6, 1) because if I go to 100 and then back there will be "%" written two times
        lcd.setCursor(5, 1);
        lcd.print("%");
    }

    if (b==100)                 //but if "b" is same as 100 then there is three digit number and we need to move "%" on Cursor(6, 1)
    {
        lcd.setCursor(6, 1);
        lcd.print("%");
    }

    if (forward3 == HIGH)   //if you click button forward "x" will go on 3 and in the void will call "drink_2"
    {
        lcd.clear();
        x=3;
    }
    

    if (back3 == HIGH)  //if you click button back "x" will go on 1 and in the void will call "choose_way"
    {
        lcd.clear();
        x=1;
    }

}





void drink_2() 
{
    lcd.setCursor(0, 0);
    lcd.print("DRINK 2:");
    int plus4 = digitalRead(plus);
    int minus4 = digitalRead(minus);
    int forward4 = digitalRead(forward);
    int back4 = digitalRead(back);
  
    lcd.setCursor(3, 1);
    lcd.print(c);
    
    if (c<100)
    {
        lcd.setCursor(6, 1);
        lcd.print(" ");
        lcd.setCursor(5, 1);
        lcd.print("%");
    }

    if (c==100)
    {
        lcd.setCursor(6, 1);
        lcd.print("%");
    }
  
    if (plus4 == HIGH && c<100) 
    {
        c= c+10;
        lcd.setCursor(3, 1);
        lcd.print(c);
        delay(200);
    }
  
    if (minus4 == HIGH && c>0) 
    {
        c= c-10;
        lcd.setCursor(3, 1);
        lcd.print(c);
        delay(200);
    }

    if (forward4 == HIGH)   //if you click button forward "x" will go on 4 and in the void will call "drink_3"
    {
        lcd.clear();
        x=4;
    }

    if (back4 == HIGH)  //if you click button back "x" will go on 2 and in the void will call "drink_1"
    {
        lcd.clear();
        x=2;
    }

}
void drink_3() 
{
    lcd.setCursor(0, 0);
    lcd.print("DRINK 3:");
    int plus5 = digitalRead(plus);
    int minus5 = digitalRead(minus);
    int forward5 = digitalRead(forward);
    int back5 = digitalRead(back);
  
    lcd.setCursor(3, 1);
    lcd.print(d);
    
    if (d<100)
    {
        lcd.setCursor(6, 1);
        lcd.print(" ");
        lcd.setCursor(5, 1);
        lcd.print("%");
    }

    if (d==100)
    {
        lcd.setCursor(6, 1);
        lcd.print("%");
    }
  
    if (plus5 == HIGH && d<100) 
    {
        d= d+10;
        lcd.setCursor(3, 1);
        lcd.print(d);
        delay(200);
    }
  
    if (minus5 == HIGH && d>0) 
    {
        d= d-10;
        lcd.setCursor(3, 1);
        lcd.print(d);
        delay(200);
    }

    if (forward5 == HIGH)   //if you click button forward "x" will go on 5 and in the void will call "drink_4"
    {
        lcd.clear();
        x=5;
    }


    if (back5 == HIGH)  //if you click button back "x" will go on 3 and in the void will call "drink_2"
    {
        lcd.clear();
        x=3;
    }

}





void drink_4() 
{
    lcd.setCursor(0, 0);
    lcd.print("DRINK 4:");
    int plus6 = digitalRead(plus);
    int minus6 = digitalRead(minus);
    int forward6 = digitalRead(forward);
    int back6 = digitalRead(back);
  
    lcd.setCursor(3, 1);
    lcd.print(e);
    
    if (e<100)
    {
        lcd.setCursor(6, 1);
        lcd.print(" ");
        lcd.setCursor(5, 1);
        lcd.print("%");
    }

    if (e==100)
    {
        lcd.setCursor(6, 1);
        lcd.print("%");
    }
  
    if (plus6 == HIGH && e<100) 
    {
        e= e+10;
        lcd.setCursor(3, 1);
        lcd.print(e);
        delay(200);
    }
  
    if (minus6 == HIGH && e>0) 
    {
        e= e-10;
        lcd.setCursor(3, 1);
        lcd.print(e);
        delay(200);
    }

    if (forward6 == HIGH)   //if you click button forward "x" will go on 6 and in the void will call "drink_5"
    {
        lcd.clear();
        x=6;
    }


    if (back6 == HIGH)  //if you click button back "x" will go on 4 and in the void will call "drink_3"
    {
        lcd.clear();
        x=4;
    }
}





void drink_5() 
{
    lcd.setCursor(0, 0);
    lcd.print("DRINK 5:");
    int plus7 = digitalRead(plus);
    int minus7 = digitalRead(minus);
    int forward7 = digitalRead(forward);
    int back7 = digitalRead(back);
  
    lcd.setCursor(3, 1);
    lcd.print(f);
    
    if (f<100)
    {
        lcd.setCursor(6, 1);
        lcd.print(" ");
        lcd.setCursor(5, 1);
        lcd.print("%");
    }

    if (f==100)
    {
        lcd.setCursor(6, 1);
        lcd.print("%");
    }
  
    if (plus7 == HIGH && f<100) 
    {
        f= f+10;
        lcd.setCursor(3, 1);
        lcd.print(f);
        delay(200);
    }
  
    if (minus7 == HIGH && f>0) 
    {
        f= f-10;
        lcd.setCursor(3, 1);
        lcd.print(f);
        delay(200);
    }

    if (forward7 == HIGH) //if you click button forward pump will start pumping drinks but i haven't done that yet
    {
      
    }

    if (back7 == HIGH)  //if you click button back "x" will go on 5 and in the void will call "drink_4"
    {
        lcd.clear();
        x=5;
    }
}