Day 11: Whack-A-Grub


Build a reflex test game for the new commander, inspired by the classic Whack-A-Mole game. The game will have multiple buttons and LEDs to test the cadets’ reaction times. The fastest cadet wins!

With the arrival of the new commander on the Nebula Raider, there is a need for engaging activities to keep the crew entertained and sharp. The commander has requested a new game that will test the reflexes of the cadets. Inspired by the classic Whack-A-Mole game, you are tasked with building “Whack-A-Grub,” a game where LEDs light up randomly, and cadets must press the corresponding button as quickly as possible. The fastest reaction time wins, providing a fun and competitive way for cadets to stay on their toes.

Components Needed:

Raspberry Pi Pico WH Microcontroller
LEDs (at least 4, different colors)

LCD 1602 I2C

Push buttons (matching the number of LEDs)
Resistors
Breadboard
Jumper wires
Instructions:

Set Up the Circuit:

Connect each LED to a GPIO pin on the Raspberry Pi Pico (e.g., GP0, GP1, GP2, GP3) with appropriate resistors.
Connect each push button to a GPIO pin on the Raspberry Pi Pico (e.g., GP4, GP5, GP6, GP7) using a pull-down resistor configuration.
Use jumper wires to make all necessary connections on the breadboard, ensuring a secure and organized setup.

Write the Code:

Open your coding environment and write the following Python code to create the Whack-A-Grub game.

Upload the code to the Raspberry Pi Pico and run it.

Test The Circuit:

Observe the LEDs lighting up randomly and press the corresponding button as quickly as possible.
Ensure the system accurately measures and displays the reaction times

Post a comment

Leave a Comment

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