The player holds his hand over the sensor for a few seconds and that starts the game. Two RGB (Red, Green, Blue) LEDs start flashing in different colors. At a random time they will stop flashing and will remain lit, with the same color (e.g. both would become Blue). The player has to react as quick as possible and move his hand away from the sensor. The reaction time is recorded. The game is keeping track of the best reaction time so far. If the player moves their hand away from the sensor, before the signal is set off (i.e. before the LEDs stop flashing and remain the same color), that's considered a "bad" attempt.
Video 1 | Video 2 |
---|---|
- Ultrasonic sensor HC-SR04
- 220 ohm resistors
- Two RGB LEDs
- IIC 0.91" OLED Display
- Some wires
- Breadboard
- Arduino Uno r3
Click image to download fzz
file
See code here. All code is implemented as non-blocking, i.e. there are no delay
calls.
The main sketch can be found here:
There is two setting files that may need adjustment:
- Settings - various settings.
- Pins layout - the Arduino pins to be setup in accordance with your own wiring.
Code responsible for rendering information on the screen:
The gameplay is driven by the code here:
The lights management is implemented here:
Detecting the player's hand using the sonar is implemented here:
Keeping track of the game 'world' is done here: