Hello,
New-ish programmer here. I'd like to design a very straight forward yes/no - true/false type of trivia game for children and was wondering if someone would be able to give me some general guidance on how to structure the programming. The game will be very simple, consisting of:
1x Arduino Uno
1x Sparkfun MP3 Trigger controlled with FTDI Serial connection.
3x Pushbuttons (Start, True, False)
8x 5v Relays that will trigger a small sections of LED ribbon that will act as a sort of visual progress indicator in the game.
The goal: Answer 8 questions correctly to illuminate a completed path through printed graphic of a downtown / city map. (LED ribbon will be used for the path).
The game goes like this:
- User presses start button to begin game
- mp3 trigger plays audio question 1
- User has 5 seconds to select the correct answer by pressing True button or False button
- If user get's it correct, they go to next question and a digital pin goes high to trigger a relay with a "digitalWrite, HIGH;". Mp3 trigger plays a "correct" sound.
- If user get's it incorrect, Mp3 trigger plays "incorrect" sound, all relays turn off, and they have to start over from the beginning i.e. question 1 and they lose all of their progress.
The game continues for 8 questions.
Each correctly answered question will trigger the next successive relay. So the user's progress in the game needs to be tracked. For example, if they've made it to question 5, then relays 1 through 4 should be lit and stay ON. Then say they get question 6 incorrect, all relays turn off and the game starts over.
I started writing the sketch for this, but I'm a little bit stuck on how to generally structure it. I realize this is probably pretty basic stuff so I hope you can bear with me. I know that I can not use delays because the buttons would be unresponsive during any delay. I assume I will have to rely on millis() for the timing. But I guess my main area of difficulty is how to break this up into 8 rounds, so the code knows to wait for the proper input for question 1, then the proper input for question 2 etc. I was thinking of maybe writing each question as it's own function, then calling the functions in the loop. No idea if that's the best way to go about this.
Thanks very much for reading!
Keith