how to program dialoge choices

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.

i've added a picture of a diagram if that helps

where does the arduino fit in?

where does the arduino fit in?

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

Your description is far from clear.

Do you want a message A to play when button A is pressed and message B when button B is pressed, etc

OR

Do you want message A to play when the button is first pressed and message B to play when the same button is pressed a second time?

OR something else?

...R

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.

OP's image:

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.

  1. the horn is picked up and a standard message will play explaining to press any button to continue.
  2. another message will play depending on which button is pressed.
  3. if another button is pressed after 2 has played a new message will play depending on which button was chosen at stage 2.
  4. if another button is pressed after stage 3 has played a new message will play depending on which button was chosen at stage 3.
  5. 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

gdjidje:

  1. the horn is picked up and a standard message will play explaining to press any button to continue.
  2. another message will play depending on which button is pressed.
  3. if another button is pressed after 2 has played a new message will play depending on which button was chosen at stage 2.
  4. if another button is pressed after stage 3 has played a new message will play depending on which button was chosen at stage 3.
  5. if another button is pressed redirect back to either stage 1 or stage 2

I am still struggling with this, and I have not found the image any better.

It reads as if the initial button pressed chooses a message - which is straightforward

But then it reads as if the next time a button is pressed it plays a message that depends on the previous button - and that does not make sense to me.

By the way, what sort of phone are you using - what is a "horn"?

...R

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.

wvmarle:
If you wonder why "horn" - have a look at the shape of the receiver of some of the very first phones.

That's why I asked. I wondered (still wonder) if he is using one of those old phones.

...R

That's why I asked. I wondered (still wonder) if he is using one of those old phones.

yes I am! for sure I thought horn was the word for 'receiver' in english.

gdjidje:
yes I am! for sure I thought horn was the word for 'receiver' in english.

I wonder if there is still confusion? I was thinking of one of these

...R

I wonder if there is still confusion? I was thinking of one of these

nope, its a wall phone. like a landline phone you had hanging on the wall/standing on your desk (I attached a photo not sure if it works)

edit: photo's never work when I try here's a link

Imgur

Image from Reply #13. See this Simple Image Guide

...R