Ready… Set… Go! Test your reaction time!
In this game, one of three LEDs will randomly light up. You must tap the corresponding capacitive sensor as quick as possible. If you don’t react fast enough, the game is over.
Materials
- 1 Arduino board
- 1 Basic Education shield
- 1 piezo speaker
- 3 LEDs
- 3 220 ohm resistors
- 3 1 M ohm resistors
- 6 black jumper wires
- 12 colored jumper wires (3 long ones)
- 1 ?breadboard
- aluminium ?foil
- masking tape
Instructions
Code
You can find the code in?File -> Examples -> Castilla -> Sports -> React
How it works
The game first waits for a random period of time and then picks a number between 0 and 2. This number represents the LED that will be turned on and the sensor associated with it. You must touch the sensor of the lit LED within the value of ?reactTime
, a cheering sound is played. The game will then repeat.
However if you fail, the program calls?gameOver()
?which blinks all the LEDs and makes sound to signal game over. The game then resets and starts again.
?
Troubleshooting
- Refer to the illustration and double check your connections. Make sure the shield and wires are firmly connected.?Check the LED polarities to make sure they are consistent and properly wired.
- Increase the allowed reaction ?time to make the game easier for testing. Make sure to change them back when everything is working.
- VU-meter does not work correctly? See?VU-Meter reference for debugging VU-meter.
- Can’t upload the code? Make sure that the?CapacitiveSensor?library is placed inside the?Arduino libraries folder.
Experiment further
- Can you make game harder to play? Change the reaction time and the waiting time.
- Not happy about the sounds the piezo plays? Make up your own melodies.
- Change the way the LEDs blink when it’s game over. See code example VUMeterTest for the commands you can use.
- Can you add more LEDs and sensors? Dont forget to add them both onto the board and into the code!