Make a Reaction Time Game
Materials
2 pieces of cardstock (one for buttons, one for the game display)
conductive tape
masking tape
micro:bit board
4 alligator clip wires
Make the Buttons
Each player needs a button made from a flap of cardstock. When you press the button, it closes the circuit between Ground (GND) and the Pin (P0, P1, or P2). This signals to the micro:bit which player hit their button first. To make the buttons:
Fold a piece of cardstock into thirds. Cut into long sections along the fold lines.
Take one of the long sections of cardstock and fold one short end partway up. Leave some of the bottom layer sticking out.
On the bottom layer, put a strip of conductive tape from the middle of the card and up over the edge. Leave a gap of about 1 inch and put another strip next to it.
Label one strip GND and the other with the Pin number it will connect to.
Connect a short strip of conductive tape to the GND tape going out to the side and folding over to the back.
On the inside of the top layer, attach strips of tape conductive tape going the other way. When you press the top of the flap down, the top strips of tape should connect the bottom strips of tape and close the circuit.
Label and/or decorate your button.
Make the Game Display
The display holds the micro:bit so the players can see it.
Fold a piece of cardstock in half. Fold the bottom edges in about 1 inch.
Unfold into a tent with the bottom flaps pointing in. Use the extra piece of cardstock from the buttons and tape it across the bottom to hold the tent open.
Label and/or decorate your display.
Add the Electronics
The buttons serve as external input for the micro:bit. Use alligator clip wires to connect the buttons to the micro:bit. It doesn’t matter what color wires you use. The wires in the photo are labeled to show you what points to connect.
Roll up some sticky-side-out loops of masking tape. Attach them to the back of the micro:bit.
Press the micro:bit onto the top of the display. Make sure to leave room for the alligator clips and the USB cable.
Take four alligator clip wires in different colors. Here’s how to connect them:
Connect the GND tapes on two buttons. (Shown as black in the photo.)
Connect the GND wire on one button to the GND pin on the micro:bit. (Shown as red.)
Connect the other strip of conductive tape to the matching Pin (0, 1, or 2). (Shown as green and yellow.)
Test the Buttons
Make sure your buttons are working by writing a program that makes something happen when you press them.
Open the starter MakeCode program
Make a program that tests each button:
Find the block that lets you use the Pin as input.
Add a block that produces output on the micro:bit when the Pin is pressed.
Download the code and test each button.
Code the Game
Use the suggested blocks in the Starter Code to add the following actions:
Looping and Logic
Start with a loop block to re-start the game after every round.
Use a logic block to check which button was pushed first.
Feedback
Add output blocks that let players know:
the round has begun.
which player won the round.
any other output you think will make the game better. (For example, signalling the start of a new round.)
Wait Time
Add a wait period so the players don’t know in advance when to press their buttons.
Vary the wait time so players have to watch for the signal to react. How can you make the wait time different for each round?
False Start
Add code that prevents a player from winning by pressing their button early.
Create a variable that can be set to “on” or “off,” like a toggle switch. Use it to indicate whether the game has started or not.
Set the variable to “on” after the wait period has started.
Turn the game off as soon as one of the buttons is pressed, so only one person can win each round.
Advanced Coding Challenges
Add code that says each player must win three rounds to win the game. How can you count the number of wins? How can you start the count over after someone wins the game?
(Answer key: 3 Rounds Version)
Change the code and the set-up to allow three or four people to play. (Hint: Try using Radio)
Basic Reaction Game
If you’re having trouble putting together a game, look at the sample below:
↓
↓
↓
↓
↓