Using our website means you agree to using cookies which help us improve microbit.org.Learn more
Skip to content

Activity

Reaction game

Advanced | MakeCode, Python | LED display, Pins | Boolean logic, Electricity, Electronics, Human body, Input/output, Iteration, Product design

Step 1: Make it

What is it?

Make a reaction game with real physical switches you can bash as hard as you like!

two home-made pressure switches attached to micro:bit pins

How it works

  • Make two physical input switches using cardboard and tin foil – similar to the ones used in the Pressure switch alarm project.
  • Connect them to the micro:bit pins as in the picture – one tin foil pad on each switch goes to the micro:bit’s GND pin, and the other is connected to pin 1 or pin 2 depending on whether you are player A or player B.
  • The program waits a random time between 1 and 5 seconds, then shows a heart on the LED display output.
  • You can’t hit your button before it lights because it uses Boolean logic to stop anyone cheating! Boolean variables can only have two values: True or False. The game started variable prevents either player pressing their button too soon by only checking which button is pressed while the game has started.
  • An infinite loop keeps the game running so you can keep playing.

What you need

  • 1 micro:bit
  • 4 crocodile clip leads
  • Some scrap cardboard, tin foil, glue and scissors

Step 2: Code it

Step 3: Improve it

  • Use variables to keep track of each player’s score
  • Add a timer to show how quick each winner’s reaction was
  • Track which player has the fastest reaction time