hi everyone!
I'm working on a project with a phone where if you press a certain button an audiofile will play.
I figured out how to do the press a button and a file will play but id like there to be a series of files where you press once, something plays, you press another time something else plays etc. etc.
right maybe that wasn't very clear, i've used an arduino to attach all the buttons, I dont know how to code in the arduino when this button is pressed after this audiofile has played this audiofile has to play.
does that make sense?
I know how to code if button 1 is pressed file 1 has to play but i dont know how to continue from there
That diagram describes a finite state machine. Press button, enter state (block). Based on in which state the thing is, it plays a certain track, then reacts (or maybe not while playing) to further button presses in a way specific to that state.
sorry im having a bit of a hard time describing what i mean, which is why i added the picture.
basically i have an old phone with 15 buttons + a button underneath the horn so the arduino knows when the horn is picked up.
the horn is picked up and a standard message will play explaining to press any button to continue.
another message will play depending on which button is pressed.
if another button is pressed after 2 has played a new message will play depending on which button was chosen at stage 2.
if another button is pressed after stage 3 has played a new message will play depending on which button was chosen at stage 3.
if another button is pressed redirect back to either stage 1 or stage 2
I find it is best explained through the picture.
basically my problem is; I know how to make it so that stage one and two can get started;
if (underhornbutton) is high play (standard message)
(perhaps add a delay here to play the whole message)
if (while (underhornbutton) is high) button 1-15 is pressed play (new message)
however I cant figure out how to make it so that it continues after that with stage 3-5
That diagram describes a finite state machine. Press button, enter state (block). Based on in which state the thing is, it plays a certain track, then reacts (or maybe not while playing) to further button presses in a way specific to that state.
that's actually a really helpful term, i've found some tutorials on how to make finite state machines with an arduino so hopefully ill be able to figure something out with that term
It looks like a relatively simple phone tree, such as you might be subjected to when you call customer support:
Press one for English -> press one for the runaround, press two to be disconnected, press three to hear a long repeating message and then be disconnected.
Simpler here in that sometimes any number will take you to the next stage.
State machine will do the job. Might be possible just to specify the state changes and corresponding sound files in an array of structs and make the whole thing data driven.
In your finite state machine, some states will be checking for button presses, other states playing a sound. Such a state could probably simply time out and move into a state that again checks for button presses.
Robin2:
By the way, what sort of phone are you using - what is a "horn"?
That's what in most English speaking parts of the world is called "receiver".
If you wonder why "horn" - have a look at the shape of the receiver of some of the very first phones. For the same reason (a generation or two less old phones) we "dial" a number.