I would like to create an arduino version of the game ready steady bang Ready Steady Bang - 2 player demo on Vimeo
My goal is to have the arduino emit 2 beeps from a speaker and then a 3rd one after a random amount of time within let's say 10 seconds. At the third beep the players would have to stop it by tapping on the A4 sheets of aluminium laid before their hands. The arduino should know who won and display the winning player using number 1 or 2 on a display seven-segment display.
I don't know where to start so I come here looking for your help. I am in possess of an arduino uno starter kit with some basic stuff I guess.
Thank you in advance for any help!
Cheers
I realise I am posting in the product design section, sorry I didn't see the project guidance section and I cannot manage to move or delete this post
Your overall project isn't difficult, though you will find it easier to break down each block of code into milestones rather than trying to achieve it all at once.
I would break it down into the following blocks of code
Draw time sequence. This covers your two beeps and third final random beep.
Response time of player 1&2
Result event. - What happens after both players have tapped.
To keep things simple lets start with the response time part of the code, and then we will determine the winner.
In this section, we are in effect using two PTM buttons, and as a result of this you will need to pull the digital inputs down to ground using a 10K resistor.
const int buttonPin1 = 7;
int button1State = 0;
const int buttonPin2 = 8;
int button2State = 0;
void setup()
{
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
}
int player1ResponseTime=0;
int player2ResponseTime=0;
int player1drawn=0;
int player2drawn=0;
void loop()
{
button1State = digitalRead(buttonPin1);
if (button1State == HIGH)
{
player1ResponseTime=millis();
player1drawn=1;
}
//second player
button2State = digitalRead(buttonPin2);
if (button2State == HIGH)
{
player2ResponseTime=millis();
player2drawn=1;
}
// now we need to check that both players have actually drawn to determine the winner.
if(player1drawn==1 && player2drawn==1) //check if both players have drawn
{
if(player1ResponseTime<Player2ResponseTime) // if player 1's time is less than player 2's he wins.
{
//Player 1 wins!
}
else // if the time is not less than player 2's, AKA player 2 was quicker, player 2 wins.
{
//Player 2 wins!
}
}
There are of course other considerations to take into account such as only allowing the person to draw once per round.. as if they accidentally tapped it a second time this would decrease their draw time to a slower speed. When coding, you need to program it in a way that its idiot proof.. predict how people will use it, frantically slapping the button trying to be quicker so you need to take into account its the first reading you want, and not all the spurious ones which follow. you will also need to think what happens if they draw early, before the third final beep... these variables are all basic, but you will have to give them so careful thought to cover all your bases.
Get your head fully around the above, and once you have, then move onto figuring out starting the round after a preset time 8)