Whack a Mole – Arduino Game (full arduino tutorial with code)

Hi, I’m Mike and I’m Chris To day we are gonna build a whack-a-mole inspired game with an Arduino and just a few other parts This is a cheap and easy build and you’ll find links to all the parts and the code in the description All you need to build this game is a box a few buttons and LED matrix and an Arduino Nano The idea of the game is to push the buttons as they light up to score points The first player to reach a score of 100 wins the game. To save time we bought ready made wooden box the first thing we did was replace the weak plywood at the bottom of the box as This is gonna be the top of the game. It has to be solid. So it will not break when the buttons are pressed We used an oscillating tool to cut out the bottom and then we clean up the edges When the bottom was out we measured and cut a half an inch thick wood plate This will act as a top of the game. We sanded the edges and used both glue and screws to secure it to the box Then we decide to cut out legs on the box to make it look better We also strengthen the legs by adding a triangle piece of wood Finally we spackled and sanded the box before we spray-painted it in In hindsight, we would just use ordinary paint and not spray paint Whenever stone we chose a pattern for buttons and drilled holes We also made room for the LED matrix that will keep the score Since the buttons extends a bit beyond the holes we were safe drilling after it was painted But it will be a better idea to do the drilling and cutting before you paint Now the box is done so let’s do the electronics The LED on the buttons are all 12 volts compatible But since we want to run everything using an Arduino Nano we needed to be 5 volts Luckily, there’s an easy fix. We just replace the current resistor with a lower ohm resistor and repeat that for all the buttons The buttons are easy to use the two terminals are just extensions of the led legs The three terminals in the middle are for the switch. We’re only going to use the common terminal and the normal open terminal Before we wire it up, let us show you a little trick Since we’re gonna connect five buttons For each player and each button requires one pin for the LED and one pin for the push button We’re going to need 20 pins on the Arduino Additionally, we need one start button that requires one pin for the LED and one pin for the button And finally, we need to connect the LED matrix display which requires three pins In total that means that we need 25 pins from the Arduino If we do not use the Rx and TX pin the Nano has 12 digital pins Additionally we can use the 8 analog pins that gives us a total of 20 pins So we’re still missing 5 pins Instead of using a shift register or do manual multiplexing We’re simply going to use a voltage divider. A voltage divider is two or more resistors connected in series that will output different voltage between the resistors This is an example where we input 5 volts and simply by connecting one 10 K resistor and 20 K resistor We get 3.3 volt in between them We’re going to use even more resistors so that we can connect all the player buttons for one player And this can be read by the Arduino on one single analog pin So instead of needing five pins for each player’s buttons, we now simply need one analog pin for each player That saves a total eight pins Here’s an example built in Tinkercad There’s a link to the schematics in the description To tidy it up we made a motherboard with screw terminals to connect to the LEDs and the buttons All you need to finish up your own game is to download the code as you will find a link to in the description They also find the links to the schematics of all the products used to this video And that’s all you need to build your own game. I hope you enjoyed this video. Remember to Like and subscribe See you next time!

22 thoughts on “Whack a Mole – Arduino Game (full arduino tutorial with code)

  1. hello friends to compile it throws me errors I would appreciate if you could upload the file to compile it directly

  2. or if someone already compiled it could pass me the file to open it directly with arduino thanks in advance

  3. You guys are amazing! I'm currently building a very similar (but smaller) game using an arduino nano, and this video helped a lot! Subscribed.

  4. Awesome build! Thanks DIY TechBros. I do have a question though…. I see you have player 1 and player 2 button on the play surface. However, i don’t see it in the schematics. Is that for further expansion?

  5. Fantastic project!
    I have a few questions…
    1. Is it possible to increase the buttons to 8 per player?
    2. Can the displays be stacked to increase the size of the display?
    3. Is it possible to add a sound effect everytime a button is pressed?
    4. Can the difficulty be changed? (flash for shorter duration)

  6. Hello! Good day. May I ask what is MD_Parola library mean? Thank you so much. It would be a great help for our project.

  7. regards, I would like to know if instead of connecting 5 buttons for a player I could connect 10 buttons per player. Thanks in advance

  8. I have 2 doubts

    1-what did the arduino feed with?

    2-of how many ohms can be the resistance that go in the LEDs?

  9. I ordered all parts and started building this for my daughter and me. So I tested the led segments and the zero is not currently aligned on the 4 segment display. They seem to be reversed. When I'm hitting the number ten, zero is left, one is right. How can I fix this?

  10. Hey Guys! Great Project! I have a question, how do you wire the Player 1 and Player 2 buttons? I don’t see them mentioned in the code. I’m currently building the exact project. Everything is working perfect. Is just the player’s button what I can’t figure out yet. Thanks guys. Cheers!

  11. Hello, Thank You for this amazing project. I need help in the case. Wene it starts all lights turn on one by one and that's all. How to start the game ? I am doing this without matrix, I just wanna test it.

  12. I have a question about Arduino coding.
    I have got a problem about compiling the code The message just pops up there is compile error and exit status 1.
    I really have no idea why that pops up comes out

  13. Guys! I have a problem with my game. For whatever reason every time a press a buttom, both displays start counting. I tried completely disconnecting one player and still both displays record once I press a button. Any ideas? The code is exactly the same, just the pin assigments are different. I'm also using an Arduino R3.

  14. I have a problem…by pressing any button the score increases…because all buttons are commonly connected to A0 or A1 and the code is also written that way …any solution

Leave a Reply

Your email address will not be published. Required fields are marked *