LED Rocker Game

by janewu331 in Circuits > Arduino

2309 Views, 4 Favorites, 0 Comments

LED Rocker Game

Arduino - LED Rocker Game

LED Rocker Game is a simple Arduino game. It mainly consists of 9 LEDs (8 Blue LEDS &1 Red LED in the middle), 1 button, 1 speaker, and 1 LCD panel. The goal of this game is to press the button when the red LED blinks. It starts with 9 LEDs blinking back and forth. When the middle red LED blinks, you have to immediately press the button. Every time you successfully pressed the button when the red LED blinks, you will go to the next level with increased blinking speed. If you press the button when the blue LED blinks, you lose one life. You have 3 lives in total, and when you lose all three lives, the game restarts. While playing this game, it also improves your hand-eye coordination and response capability.

Source: https://www.instructables.com/id/Arduino-LED-Rocke...

The concept and rules of my game and the game I referred to are similar, but I added some features that could help the players understand the game more and make their gaming experience even better. In this game, I added a speaker and an LCD panel. Also, since I added an LCD panel, the digital pins I used in my game will be different from the digital pins in the game I referred to (I changed digital pin 2&3 to 11&12). By listening to the sound and looking at the LCD screen, players can directly know whether they passed the level or not, and when the game starts over again, the sound and screen will remind you. Therefore, you won't be confused about whether you passed or lost during the game.

Supplies

螢幕快照 2020-04-14 下午9.10.14.png

- 1 Arduino Leonardo

- 1 Breadboard

- 9 LEDs (1 Red, 8 Blue)

- 9 Resisters (10kohm)

- 1 Resister (300kohm)

- 1 Button

- 1 LCD Panel

- 1 Speaker

- Jumper wires

LED & Button

IMG_2903.JPG
IMG_2904.JPG
IMG_2905.JPG

After getting all the supplies you need, the second step will be to connect all the LEDs and the button to the breadboard and Arduino. Arrange the jumper wires, button, LEDs, and resistors in the same order on a Leonardo breadboard according to the picture above. The LEDs should be connected with a resistor (10kohm) from digital pin 4 to 12. Since we are going to connect the LCD panel later, make sure you don't use digital pin 2 and 3. For the button, connect it to digital pin 13 with a resister (300kohm).

Speaker

IMG_2907.JPG
IMG_2909.JPG
IMG_2908.JPG

After connecting the LEDs and the button, the third step is to connect the speaker to the breadboard. Connect the negative side (black) to the GND pin and the positive side (red) to digital pin 1. The speaker will make different sounds when you successfully pressed the button (when the red LED blinks), pressed the button when the blue LED blinks, and when you lose all three lives (the game restarts).

LCD Panel

IMG_2911.JPG
IMG_2913.JPG
IMG_2912.JPG

After connecting the LEDs, button, and speaker, the fourth step (last step for the circuit) is to connect the LCD panel to the breadboard. The LCD panel is separated into 4 main steps to connect (GND, VCC, SDA, SCL). Connect GND to the corresponding GND pin on the Arduino, VCC to 5V pin on the Arduino, SDA to the corresponding SDA pin on the Arduino, and SCL the corresponding SCL pin on the Arduino. After you pressed the button, the LCD panel will show on its screen whether you passed the level, lose a life, or start the game over again.

Code

螢幕快照 2020-04-12 上午11.26.07.png
螢幕快照 2020-04-12 上午11.26.20.png
螢幕快照 2020-04-12 上午11.26.42.png

After finishing the circuit, you can start writing the code.

Code: https://create.arduino.cc/editor/janewu/5e2f287b-9...

Transfer the code onto your circuit board. Make sure to transfer your code by connecting the board to your desired device. After you finished transferring the code, you can try the game and see whether it works properly.

Container

IMG_2914.JPG
IMG_2916.JPG
IMG_2917.JPG
IMG_2918.JPG

After finishing and testing the circuit and code, you can make a container for your Rocker game. This not only makes the whole device look better and professional but also provides you better gaming experience. For the container, I used a cardboard box to hold all the entire breadboard and all the materials used. I covered the box with black paper and cut out holes for the speaker, LCD panel, button, and LEDs. Make sure you also cut a small hole on the side of the box so you can connect your device to a power bank.

Cardboard box:

  • Length: 22cm
  • Width: 12cm
  • Height: 8cm

Hole for LCD panel:

  • Length: 8cm
  • Width: 2.5cm

Hole for LED:

  • Length: 5cm
  • Width: 0.5cm

Hole for speaker:

  • Diameter: 3.5cm

Hole for button:

  • Diameter: 3cm

Hole on the side:

  • Length: 1cm
  • Width: 1 cm

After you finished making the container, place your device inside the container. Make sure you place the LCD panel, speaker, button, and LED to their corresponding holes.

Play the Game!

Arduino - LED Rocker Game
IMG_2923.jpg

Connect the device to a power bank or computer and try the game!

Rules:

  1. Press the button when the middle red LED blinks
  2. If you successfully press the button when the red LED blinks, you go to the next level (the LEDs will increase their blinking speed each time you level up)
  3. You lose a life if you press the button when it's not on the red LED
  4. You have 3 lives in total. If you lose all three, the game starts over again