Whack-a-mole!

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.

Step 1

Step 1

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.

Step 2

Step 2

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.

Step 3

Step 3

Then, follow this piece of code. This declares the variables required to play the game.

Step 4

Step 4

Declare the arrays.

Step 5

Step 5

Add this chunk of code before the void setup.

Step 6

Step 6

Add this code under the previous.

Step 7

Step 7

In the void setup, add the following code.

Step 8

Step 8

Add the top of the code in the void setup. Add the rest in the void loop.

Step 9

Step 9

This code goes under the previous chunk in the void loop.

Step 10

Step 10

Add this in the actual void loop, not in the if else code.

Step 11

Step 11

This is the code after the void loop that calls the function lightUpPin.

Step 12

Step 12

This is the function called spoonHit.

Step 13

Step 13

Add this under the first chunk of spoonHit.

Step 14

Step 14

Final chunk of code to be added to spoonHit.

Add a comment