Skip to content

Reaction Timer

Wait for an LED cue and measure a button response while rejecting early presses.

Reaction Timer: the matching Arduino Uno circuit rendered in Circuitera’s simulator
Matching Circuitera simulator circuit. Real firmware capture; modeled components are idealized.

Wire it up

Disconnect power before changing connections. Follow terminal names rather than wire colors.

FromToWhy it matters
Uno · 13Resistor (r-led1) · 1Match this terminal to the sketch
Resistor (r-led1) · 2LED (led1) · AMatch this terminal to the sketch
LED (led1) · CUno · GND.1Ground reference
Pushbutton (button1) · 1.lUno · 2Match this terminal to the sketch
Pushbutton (button1) · 2.lUno · GND.2Ground reference

The complete sketch

reaction-timer.ino
unsigned long readyAt, litAt;
bool lit = false, finished = false;
void setup() {
  Serial.begin(9600); pinMode(2, INPUT_PULLUP); pinMode(13, OUTPUT);
  randomSeed(analogRead(A5)); readyAt = millis() + random(1500, 4000);
  Serial.println("Wait for the LED, then press.");
}
void loop() {
  if (finished) return;
  if (!lit && (long)(millis() - readyAt) >= 0) {
    digitalWrite(13, HIGH); lit = true; litAt = millis();
  }
  if (digitalRead(2) == LOW) {
    if (!lit) Serial.println("Too early. Restart to try again.");
    else { Serial.print("Reaction ms: "); Serial.println(millis() - litAt); }
    digitalWrite(13, LOW); finished = true;
  }
}

The launch buttons use this same code and a matching saved circuit.

Build it step by step

  1. Open a complete project

    Launch in Simulator creates a separate Uno sketch and its matching wired circuit. Existing sketches are preserved. Press Run to compile and execute.

  2. Explore the live circuit

    Run and wait for the LED before pressing. Restart for another attempt; try an early press once to see the guard.

  3. Try it on hardware

    Disconnect power while wiring. Match terminal names in the table, select the exact board, Verify, then connect and upload. Check component ratings and power requirements first.

Understand the sketch

Explicit states

Waiting, lit, and finished are separate states. The timestamp is captured when the LED lights. An early press ends the attempt rather than granting a false fast score. Simulation timing is not a human benchmark.

If something is different

The next attempt never starts

This sketch deliberately allows one attempt per run. Restart; randomSeed on a floating pin is not a secure random source.

Expected output and tested scope

After the LED cue, a button press prints Reaction ms; an early press reports Too early.

Version 1 · Last source- and build-matched test: 2026-10-25. Actual shipped AVR-GCC WASM compilation and Uno AVR engine execution; no physical hardware test.

Supported tutorial target: Arduino Uno R3 / ATmega328P. Compile: PASS · Modeled execution: PASS. Other boards require a separate review of pins, voltage, libraries and the exact build profile.

Keep exploring.