While button held and release

Hey there!
Got a total noob question here.
I have 3 small wav files i'm planning on using in sequence on an arduino teensy board.
The 3 files are small enough to fit onto the cards built in memory so i don't need a memory shield.
The audio output sequence is to be initiated by pressing and (holding down) a button.
I need for the first wav file to play once.
Followed by the 2nd file.
This 2nd file needs to be played in a loop until the button is released.
When the button is released i need the 3rd file to be played once.

Any coding advice for this would be appreciated. :slight_smile:

Any coding advice for this would be appreciated.

Do you know how to read an input and determine if it is currently HIGH or LOW ?
Do you know how to read an input and determine if has changed since it was last read ?

How many different states can the whole system be in ? Set up a variable to hold the current state number and code to execute when in that state. When something happens to change the system state, such as detecting a button press, change the state number and execute the code for that state. Congratulations, you have just implemented a state machine. It sounds scary but isn't.