Can i wait for an input

Hello Guys,

I need some help please, can someone please explain if i can do the following and if so how.

I want to write a program to introduce something i have made, but i want to make it interactive using the serial out to print instructions on the screen.

On my board i have 3 input switches and so i want to ask the user to push the switch.

For example.

Serial.println ("Hello, please press switch 1 to continue...");

Blah blah

Serial.println ("Please press switch 2 to continue...");

Blah blah

Serial.println ("Please press switch 3 to continue...");

Now i know i can put these in the setup section so it only displays once but how do i make the device sleep untill it recieves that input on that switch and if so how do i ensure it is a good press and not a bounce.

If someone could start me off please, i know the basics about Serial.begin(9600); etc... and declare all the inputs pinMode(2, INPUT); etc...

but how do i do the wait for an unlimited amount of time/sleep untill switch 1 is pressed and then awake do then do this and then sleep for another unlimited amount of time etc... until the next switch is pressed.

This only needs to be repeated once and so once finished the user can just press RESET.

Please advise

Kindest Regards


ive found this

while (digitalRead(A1)==0)
delay(10); // debounce

it seems to work, is there any cons and pros to using it?


Delay consume memory.

You can also use switch Case :

Delay consume memory.

So does any code.
"delay" consumes processing cycles unproductively, which is more important.