Ultrasonic Reaction Time Game Using Arduino and OLED
by devkrishnavhora in Circuits > Arduino
47 Views, 0 Favorites, 0 Comments
Ultrasonic Reaction Time Game Using Arduino and OLED
The Ultrasonic Reaction Time Game is an interactive Arduino-based project that measures a player's reaction time using an ultrasonic sensor.
The player places their hand near the ultrasonic sensor. When the hand reaches a distance of 5 cm or less, the Arduino detects it and starts the reaction timer. When the player moves their hand away from the sensor, the Arduino calculates the time taken and displays the result on an OLED display.
The project is useful for learning about ultrasonic distance measurement, timers, OLED displays, conditional statements, and Arduino programming.
Supplies
Components Required
Deshbot shield
Arduino Uno
HC-SR04 Ultrasonic Sensor
0.96" OLED Display 128×64
Pin Connections
Ultrasonic Sensor
HC-SR04Arduino Uno
VCC - 5V
GND - GND
TRIG - A0
ECHO - D13
OLED Display
OLEDArduino Uno
VCC - 5V
GND - GND
SDA - A4
SCL - A5
Working Principle
The HC-SR04 ultrasonic sensor sends an ultrasonic pulse and measures the time taken for the echo to return.
The Arduino converts this time into distance.
When the measured distance becomes 5 cm or less, the Arduino starts the timer.
The OLED displays:
READY → GO → REACTION TIME
When the player's hand moves farther than 5 cm, the Arduino stops the timer and calculates the reaction time in milliseconds.
The best reaction time is also displayed on the OLED.
Game Flow
Features
- Ultrasonic distance detection
- 5 cm detection point
- Reaction-time measurement
- OLED graphical display
- Reaction time displayed in milliseconds
- Best reaction time tracking
- Simple and interactive game
- No external buttons required
Programming Concepts Used
Ultrasonic Distance Measurement
The Arduino uses the HC-SR04 sensor to measure the distance of the player's hand.
micros()
The micros() function is used to measure very small time intervals accurately.
Conditional Statements
The program uses if conditions to determine whether the hand is within or outside the 5 cm detection range.
OLED Display
The OLED displays the current game status, reaction time, and best time.
Variables
Variables are used to store:
- Distance
- Start time
- End time
- Reaction time
- Best reaction time
Example OLED Output
Ready
Game
Result
Applications
This project can be used as:
- A reaction-time game
- A classroom electronics project
- An Arduino programming demonstration
- A STEM learning activity
- A demonstration of ultrasonic sensors
- A practical example of measuring time using Arduino
Downloads
Conclusion
The Ultrasonic Reaction Time Game combines an Arduino Uno, HC-SR04 ultrasonic sensor, and OLED display to create an interactive reaction-time measurement system.
The project demonstrates how a microcontroller can detect distance, measure time, process the result, and display information to the user. It is a simple project but introduces important concepts used in embedded systems and interactive electronics.