Introduction: Arduino Reaction Timer With a Servo

This is an interesting circuit which will help you test your reaction time.

Step 1: Materials

The list of materials needed to build this circuit is very simplistic:

  • Arduino
  • Breadboard
  • 2 x LED (any 2 colors)
  • 2 x 220k resistor
  • 10k resistor
  • Push button
  • Servo motor
  • Wires
  • USB cable (A - B)
  • Arduino IDE

Step 2: Building the Circuit

This project will contain 4 circuits:

  • 2 LED circuits
  • 1 push button circuit
  • 1 servo motor circuit

Useful tip:

When you are building the circuit, make sure that you leave enough space around the button so that you can easily press it.

The LED circuits

The LEDs are each connected to a digital port on the Arduino. You can also control the LEDs setting up the digital ports to either HIGH or LOW in the code. Each LED is also connected to a 220 resistor.

The push button circuit

The push button is also connected to a digital port. When the button is not being pressed down upon, the digital port is connected to ground, which is "LOW". When the button is being pressed the digital port will connect to the 3.3V which will be "HIGH". The button uses a 10k resistor.

Servo motor circuit

The servo motor is also connected to a digital port, ground and also 5V. You can control the servo motor by setting up the digital port with Servo1.write (with any degrees between 0-180).

Step 3: The Code

Here is the whole code in a written form. I will also provide a downloadable version at the bottom of this step:

Helpful hint:
On the initial part of the coding, where it says; int ledGreen=2; and int ledYellow=4; you can say led and then you can put any color that you have for your LEDs, you can say for example; ledRed, but it should be named after the color of the LED you are using for the ease of coding. I named mine with these colors because it is the colors that I have used when making my circuit.

int ledGreen=2;

int button=7;

int ledYellow=4;

int startTime=0;

int endTime=0;

int reactionTime = 0;

#include int servoPin = 3;

Servo Servo1;

void setup() {





Serial.begin(9600); }

void loop() {



















reactionTime = endTime - startTime;

if (reactionTime < 180){//Make servo go to 180 degrees Servo1.write(180); delay(1000);



if (reactionTime < 260){//Make servo go to 90 degrees Servo1.write(90); delay(1000);



while (digitalRead (button) == 0) { }

while (digitalRead (button) == 1) { }


Step 4: Testing It

Here is what should happen when you run the program:

  • The first LED should start flashing which would indicate that the game can start now
  • Push the button to begin the game
  • The game begins and the program waits a random time between 1 and 7 seconds, while all of the LEDs are turned off
  • The second LED lights up after the random time the board has generated
  • Press the button as quickly as possible
  • Right after pressing the button, the servo motor will turn either 180 degrees for fast and 90 degrees for slow
  • Press the button again to reset the course

Step 5: Additions

Use your critical thinking skills and evaluate if you can use any other gadgets on the circuit or can you use the previously used gadgets in other ways? Can you maybe?:

  • Add a display onto the Arduino circuit in order to show the exact reaction time that you have had when doing that test
  • Can you program the servo motor to do some other actions in order to show you how fast you were with your reaction time?
  • Can you maybe make the servo motor go 180 degrees and back when your reaction time was under 200 ms and not spin at all or just go to 180 degrees when it was above 200 ms?