LED Whack-a-mole

by 791295 in Circuits > Arduino

1089 Views, 1 Favorites, 0 Comments

LED Whack-a-mole

screen_shot_2018-04-08_at_4_QbwJaeCk8r.png

This game of "Whack-a-mole" utilizes seven LEDs and a joystick. There are 4 "moles" on my board, represented from the left by the 3rd, 4th, 5th, and 6th LEDs. One of these four LEDs will light up randomly and will offer a fixed amount of time to hit the corresponding direction on the joystick. I set the LEDs in a way so that the choices on the joystick are from left to right: left, down, up, and right.

Supplies

1. Arduino UNO

2. 7 LEDs (3 green, 2 red, and 1 yellow

3. 7 resistors 330 ohm

4. 1 ps2 joystick

5. Wires

6. A small shoebox

Gather All the Materials

You do not need any fancy tools to make this project. Instead of the 330-ohm resistors, you can also use 220-ohm resistors. If you color code the LEDs and the wires then that makes it easier to play on harder levels.

Follow the Schematic

screen_shot_2018-04-08_at_4_QbwJaeCk8r.png

Everything should match the real picture of the project except for the joystick. My joystick has 5 pins, 4 of which I have used: named from top to bottom "Y", "X", "Bt", and "VCC", and "GND" is connected to GND and 5V on the Arduino, "X" and "Y" are connected to A0 and A1. You can also use the 5th pin of the joystick but you will have to add one more LED (one more mole) and also add the code for that.

How to Play the Game

IMG20190614103209.jpg

The two lights on the left are red and green, which indicate an incorrect or correct choice. The yellow light to the far right blinks the count for the current high score, and it indicates the score every time a run is over (whenever a wrong choice is made). In order to score a point, you will have to hit the corresponding direction on the joystick when an LED randomly lights up in a fixed amount of time.

Difficulty Levels

IMG20190614103144.jpg

The difficulty levels that I have written into my code as constants are the time in milliseconds that the person has to make a selection. You can mess around with these times to change the difficulty for your own preference.