En garde! Test your reaction time against an opponent!
In this game, two players will hold tilt switch swords. When the green LED randomly lights up, the first person to swing their sword wins.
Materials
- 1 Arduino board
- 1 Basic Education shield
- 2 Tinkerkit tilt switches
- 2 Tinkerkit long cables
- 1 big red LED
- 1 big green LED
- 2 big yellow LEDs
- 4 220 ohm resistors
- 4 black jumper wires
- 4 coloured jumper wires
Instructions
Code
You can find the code in File -> Examples -> Castilla -> Sports -> Fencing
How it works
When the game begins, the red LED lights up indicating both of players should hold their tilt switch sword upright and wait. The program waits for a random period of time, after which the red LED will turn off and the green LED will turn on. The game then waits for either of the tilt switch swords to swing, and the first to do so will be the winner. The yellow LED on the winners side will light up for a few seconds, and the game starts over again.
Troubleshooting
- Refer to the illustrations 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.
- You hit first but your friend wins? Try swapping your tilt switch swords.
- Nothing happens when you are swinging the sword? Make to hold the tilt switch upright on red and wait for the green light, and see the reference for debugging tilt switches.
- VU-meter does not work correctly? See reference for debugging VU-meter.
Experiment further
- Construct a couple of swords to house the tilt switches inside.
- Change the winning conditions. Can you make it so that the person who is first to swing the sword up and down five times is the winner?