For Loops

I'm building a automated lemonade stand that has a coin acceptor and a button:

#1. Is it possible to have a for loop inside of another for loop?
(It waits for them to stick in a coin then waits for them to push the button.)

#2 Is there any way to get a Boolean when a coin is inserted? I followed this tutorial and it didn't work. :slight_smile:

1.Yes. Probably want a while loop inside main loop:

void loop(){
coin_slot = digitalRead(coin_detector);  // whatever you to detect coin was inserted
 if (coin_slot ==1){  // coin_slot is 1 when coin is accepted
   while (digitalRead (button_press)==HIGH){ // button_press makes the read return Low
   // hang out waiting for button press
  // do button press action