Whac-A-Button With Arduino

Whac-A-Mole like game with Arduino and Arcade style LED buttons

 

This is a very simple version of the Whac-a-mole game, where a button lights up and waits for the player to hit it. If the correct button is hit the score is updated and a new button lights up. The player is not punished if they hit the wrong button. Only one button lights up at a time. Time to hit the button reduces each game cycle.

arduino-whac-a-button

Hardware:
5 LED buttons
All required wires, screws and nuts
Arduino nano
Laser cut acrylic panels
4 digit 7 Segment display TM1637
USB cable

DXF files available at Thingiverse

Download the code from GitHub – Whack-a-button

Assembly

Start by adding the display and buttons. Make sure the display pins are pointing inwards, the colour arrangement of the buttons is up to you.

arduino-whac-a-button-assembly-1

Use 2 screws to secure the display in place.

arduino-whac-a-button-assembly-2

Keep all buttons in the same orientation – it will make wiring easier.

arduino-whac-a-button-assembly-3

arduino-whac-a-button-assembly-4

Wiring might look messy but it’s very simple.

led-arcade-button-connection-arduino

Connect all grounds together using the daisy chain 2.8mm crimp connectors. Again if all buttons are in the same orientation it will be much easier. The end with a jumper wire connect to the Arduino GND.

arduino-whac-a-mole-wiring-1

Now connect the rest of the pins as shown in the images below:

led-arcade-button-connection-arduino-1

arduino-whac-a-mole-wiring-2

arduino-whac-a-mole-wiring-3

Connect the display.

Display –  Arduino

CLK    –   Pin 8

DIO     –   Pin 7

GND    –  GND

5V        –  5V

arduino-whac-a-mole-wiring-display

Use jumper wires to connect all LEDs to the Arduino pins.

LED1 – Pin9

LED2 – Pin10

LED3 – Pin11

LED4 – Pin12

LED5 – Pin13

arduino-whac-a-mole-wiring-4

Now use jumper wires to connect all buttons to the Arduino pins. Make sure that if you’ve used for example the green button for LED1 you’ll have to use it as Button1 as well.

Button1 – Pin2

Button2 – Pin3

Button3 – Pin4

Button4 – Pin5

Button5 – Pin6

arduino-whac-a-mole-wiring-4-1

Tape the wires together to keep them from disconnecting.

tape-wires

Once everything is connected test if it works before assembling the panels.

arduino-whac-a-mole-wiring-testing

Code

Download the code from GitHub – Whack-a-button and upload it to the Arduino.

At start the game will be in waiting for input where all LEDs will be flashing until one of the buttons is pressed and that’s when the game will start. After the game ends it will return to the waiting for input state while still showing the latest score and it will stay like that until a button is pressed and new game starts.

After you’ve checked that everything is connected correctly assemble the rest of the panels.

arduino-whac-a-mole-assembly-5

arduino-whac-a-mole-assembly-6

Leave the right panel last as that’s where the usb cable will be coming out.

arduino-whac-a-mole-assembly-8

arduino-whac-a-mole-assembly-9

Enjoy your play.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

Create your website at WordPress.com
Get started
%d bloggers like this: