← Capstone projects

Reaction game

Design a reaction timer: an LED lights after a random wait, the player presses a button, and the game shows their time in milliseconds, fairly.

Who in the class has the fastest reactions? To find out fairly, the game has to stop people guessing when the light will come on.

Client: the class, for a lunchtime competition. Context: two players take turns.

Brief: after a random wait of 2 to 5 seconds an LED lights; the player presses a button; the game shows the reaction time in ms. Pressing before the light is a false start and must be caught. Kit parts only; USB power; it must explain itself on the serial monitor or an LCD.

InquireRead the brief: who it is for, what it must do (criteria) and the limits (constraints).

Inquire: the brief

Sort each line of the brief: a criterion (what it must do, which you can test) or a constraint (a limit you must work within)?

Waits a random 2 to 5 s before lighting
Shows the reaction time in ms
Catches a press before the light (false start)
Kit parts only
USB power

DevelopPlan before you build: parts, circuit, code and the tests you will run.

Develop: plan before you build

Put the game's loop() in order.

Pieces (click to add)
    Your program

      The LED lit at millis() = 41200 and the button was pressed at 41487. What is the reaction time in ms?

      CreateBuild it, first in the simulator, then for real if you have the kit. Expect a few tries; that is normal.

      Create: build it

      TestRun your tests and record what happened, including what failed.

      Test: run your table

      EvaluateJudge it against each criterion, and say what you would change.

      Evaluate: against the brief

      Which is the strongest evidence that the design meets a criterion?

      For teachers

      A Years 8–9 design project: a fair reaction timer with a random wait, a button and millis(), planned as an ordered loop with a false-start test, built in Tinkercad and optionally on hardware, tested and evaluated. About 150 minutes.

      Open the teacher guide: answers, solutions, slides and a worksheet.

      Students will be able to

      Before class

      random(2000, 5001) and millis() are new: give them as a recipe card. A first version with delay() for the wait cannot catch false starts; that limitation is a good Evaluate point and a reason for the millis() version.

      If you assess with MYP Design, the steps line up with the criteria:

      Running the lesson

      1. Develop: ask how the game could know about a press during the wait.
      2. Test: the class tries to cheat it.

      The hard part (on purpose)

      The false start is the hard part: it needs the button checked during the wait, not delay(). Let students meet the problem with delay() first.

      When students get stuck

      Stretch and support

      Stretch: Keep the best time of the session, and show a two-player result.

      Support: A recipe card for random and millis, and the loop with the false-start check given.

      Where it leads

      Other Years 8–9 projects: Smart plant monitor, Parking assistant.

      What each step is for

      Now you can
      Next lesson4. Two-motor drive baseDesign a small robot base that follows a line or avoids obstacles: two motors through a driver, a battery chosen against the brief, gearing and a chassis, tested on a course.