We have coded a Whack-A-Mole where the LEDs light up when you hit the corresponding aluminium foil pad. You have three chances to get it wrong and it gets faster and faster as the game progresses.
Connect an alligator clip to the spot D2 and the first pad on your created board. To create a board, wrap 6 pieces of aluminium foil around a strip of cardboard. Make sure none of the aluminium strips are touching.
Connect the rest of the wires from the board to the following ports – Second pad to D4, Third pad to D5, fourth pad to A1, fifth pad to A2 and sixth pad to A3. Then, connect a spoon to port GND.
Then, follow this piece of code. This declares the variables required to play the game.
Declare the arrays.
Add this chunk of code before the void setup.
Add this code under the previous.
In the void setup, add the following code.
Add the top of the code in the void setup. Add the rest in the void loop.
This code goes under the previous chunk in the void loop.
Add this in the actual void loop, not in the if else code.
This is the code after the void loop that calls the function lightUpPin.
This is the function called spoonHit.
Add this under the first chunk of spoonHit.
Final chunk of code to be added to spoonHit.