What's needed is called a "State Machine"
enum states
{
CHOOSE,
SELECTED,
PAY,
VEND,
THANKS
}
states currentState = CHOOSE;
void loop() {
switch(currenentState)
{
case CHOOSE:
// code todo this:
// 1. LCD display "Welcome Vendo" "Choose Item".
// 2. Turn LED on.
currenentState = SELECTED;
break;
case SELECTED:
// code todo this:
// 3. button1 - 4 represents the 4 trays inside the vending machine.
// 4. if button1 is pressed, LCD displays "Item 01 is selected" "Insert Coin". Turn LED off
currenentState = PAY;
break;
case PAY:
// code todo this:
// 5. If the Coin Acceptor pulse == itemAmount of item 01, display the Amount digits everytime a
// coin is inserted. Blink LED twice.
currenentState = VEND;
break;
case VEND:
// code todo this:
// 6. Vending item and LCD displays "Vending Item" "Please Wait".
currenentState = SELECTED;
break;
case THANKS:
// code todo this:
// 7. After the process, LCD displays "Item Vended" "Thank you".
currenentState = CHOOSE;
break;
}
}