Arduino Fastest Reaction Time Game for 1-4 Players

4,049

37

13

About: Engineer, tinkerer, outdoor enthusiast, dad. I enjoy building fun and useful things out of wood and electronics and showing my kids that the process of creating can be as rewarding as the final product.

Introduction

The official Arduino starter kit with tutorials is a fantastic way to learn the basics and all the of the various things you can do and I can't recommend it highly enough. But once I had gone through making LEDs blink, buzzers buzz, and motors turn I thought about how I could turn that into something my kids and I could enjoy playing with, and this is the result: a fun, fully featured and functioning 4 person fastest reaction time game. This game can be built using nothing but parts from the Arduino starter kit. This tutorial includes an optional 74HC595 chip (a very common and inexpensive integrated circuit available in almost any expansion pack or on their own) that can be omitted without much impact on the final result. This will be explained in more detail in the steps.

Features

  • 1-4 players
  • A random delay with pulsing yellow light after the start button is pushed.
  • After the random delay a white light, piezo sound, or both signal time to go; the fastest player to press their button wins!
  • The winning time is shown, as well has how long behind the winner each player is.
  • One player can play on their own to try and best their time.
  • Players are disqualified if they press their button too early :)
  • Full instructions are shown on the LCD at each step, but players don't need to be of reading age. My 3 year old loves to play.

Parts List:
Arduino Uno or Nano (Or compatible clone). I used a Nano clone for my build.
Jumper Wires (Various colours and lengths)
3x small breadboards (or a couple larger ones)
8x 220 Ohm Resistors
6x 10K Ohm Resistors
2x - Standard pushbuttons. I used a green and red one.
4x - Arcade style push buttons with built in LEDs.

1x LCD alphanumeric (16x2 characters or larger)
1x piezo or equivalent small speaker
1x 10K potentiometer
1x White LED
1x Yellow LED
1x Nine Volt Battery holder clip
1x simple two position switch.
Materials for your case (I used plexiglass, screws, and some wood scraps)

Optional Parts

1x 74HC595 chip
4x coloured LEDs (blue, green, yellow, red)

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Download the Code for the Game and Compile / Upload It to Your Arduino

If you've never sent any code to your Arduino before, please read up and try a simple tutorial from the Arduino website before continuing. https://www.arduino.cc/en/Guide/HomePage - read on once you've successfully got a simple program working on your board or have done so before.

Why the code before the circuit?

It may seem like putting the code on first before you've built the circuit is doing things backwards, but this will allow you to build parts of the circuit and to test as you go. If you build the whole circuit, then put the code on and test, it is harder to isolate circuit problems, and not wiring things correctly the first time is an inevitable part of the fun :) . I've added a routine to the code that always executes right after boot that cycles through lighting all the LEDs, sounding the piezo, and displaying text on the LCD so you'll know if you have most things wired correctly.

Compatibilityand IDE suggestion

I have tested that this code works on the Arduino UNO and NANO. It may work on others but this is untested. For IDEs, the code provided is compatible as is with the Arduino IDE at https://www.arduino.cc/en/main/software and also PlatformIO http://platformio.org/platformio-ide - if you have another IDE that you use it will most likely work but is untested.

If you just want to get the code on your Arduino and don't know or care to know about the programming aspect, the Arduino IDE works just fine and is nice and simple. If you want to do any serious development or tinkering, I'd suggest PlatformIO or another more advanced IDE as the Arduino IDE lacks some pretty standard features like code complete and is really only designed for single file projects which this is not.

Getting the code on your Arduino

I have published the code in a public github repository. If you are a coder, feel free to improve the game by making pull requests. https://github.com/plocke/arduino-fastest

If you just want to get going, follow these steps:

  1. Download the latest version of the stable code at https://github.com/plocke/arduino-fastest/archive/...
  2. Unzip the archive. Then:
    1. If you are using the Arduino IDE, put the just 'fastest' directory alongside your other projects and open the fastest.ino file.
    2. If you are using PlatformIO, just take the whole unzipped archive as your project.
  3. Upload the code to your Arduino as you would any other project.

A note on drivers for Arduino clones

If you're not using a branded Arduino (meaning you're using a cheap clone, nothing wrong with that, they work great in my experience) you may need to install a driver as they use a different chipset to communicate with your computer. I found a driver for my nano clones (linked from the parts list) here http://kig.re/2014/12/31/how-to-use-arduino-nano-m...

Step 2: Build a Full Prototype Circuit. Test As You Go.

The next step is to build the circuit; see the attached schematic images or follow the links below. I have fully built out the circuit virtually at circuits.io for you to follow. Note these pages load very slowly. Give them some time.

Breadboard view: https://circuits.io/circuits/3000931-arduino-four-...

Schematic view: https://circuits.io/circuits/3000931-arduino-four-...

Parts list: https://circuits.io/circuits/3000931-arduino-four-...

Test each part as you go, and don't get frustrated - it is very easy to make wiring mistakes. You do not need a battery during this phase, as you can power the prototype with your USB connection. (Actually you don't need a battery at all if you're willing to power the game via a USB cable all the time, but it makes it less portable and means you always need a USB power source or laptop to plug into)

As mentioned in the introduction if you don't have a 74HC595 chip, you can leave out that portion of the circuit with the 4 'winning' LEDs. The only thing you won't get is the winner's button lighting up (if you're using arcade style buttons with built in LEDs) and it really isn't a big deal at all.

Replacing the arcade button LEDs

The arcade buttons I link to in the parts list are designed for 12V. This doesn't matter for the switc part, but it does mean the lights will be very dim as the arduino will only send 5V to them. Luckily they are easily replaced with your own LEDs: Simply twist the bottom, open them up, and pull out the 12V LEDs and replace them with your own

Step 3: Think Through Your Case, and Harden Your Circuit With Hot Glue

If you like to solder, you can certainly solder your circuit or parts of it. However, given the inexpensiveness of small breadboards and how much time it saves, I prefer to simply hot glue everything in place once I've thoroughly tested the circuit. It is fast, stable, and means you don't have to unbuild your circuit once it is working.

I did solder a few things in my build where jumper wires were connected to things not by breadboard to ensure a good connection, such as the wires to the power switch and the arcade switch terminals. If you don't have a soldering kit or are not comfortable soldering, just ensure the wire is tightly wrapped to the metal terminals of the switches before adding a drop of hot glue.

A couple tips from my experience: Before you glue anything, decide how you want things laid out in your final case. I ended up using three breadboards:

  • One is attached to the inside top of the case, and holds the LCD and wait/go lights so they are central and visible to all the players
  • One just has the Arduino Nano with lots of outgoing jumper wires and is mounted at the edge on the bottome so its USB port is available.
  • One is mounted in the middle bottom and holds all connections to the Arcade buttons and the winning lights and the 74HC595 chip.

You can see my final build from a few angles in the next step.

Step 4: Put It All in a Case, and Enjoy!

This step took me much longer than I thought it would. Take your time. There are number of things to consider when putting your circuit in your case:

  • This is a game for up to four people. Don't make it too small
  • You'll want to leave ability to open your case up and inspect/fix your circuit if anything comes loose and stops working correctly.
  • Look at the annotations on my pictures on this step for additional tips

Extending the game through code

I have a few feature ideas that I have not had time to implement - if you implement any of these please be sure to submit your code back to the project through a pull request:

  • Keeping track and displaying the fastest time since boot when no game is happening
  • Keeping track of the top 3 times persistently and displaying those as part of a no-game loop (through EEPROM reads/writes)
  • Giving each colour their own winning sound as in addition to just a light

Thanks for reading, and I always appreciate comments seeing others' completed builds, and also feedback on if anything is confusing, missing, or how anything could be easier to follow.

Lights Contest 2017

Participated in the
Lights Contest 2017

Microcontroller Contest 2017

Participated in the
Microcontroller Contest 2017

Share

    Recommendations

    • Indoor Lighting Contest

      Indoor Lighting Contest
    • Make It Fly Challenge

      Make It Fly Challenge
    • Growing Beyond Earth Maker Contest

      Growing Beyond Earth Maker Contest

    13 Discussions

    0
    None
    ChrisL70

    6 months ago

    Ironman, can't thank you enough for the great Instructable! For a Grade 7 science project, my daughter was looking to test Reaction Time of athletes, gamers, etc. This was my first time taking on an Arduino project (not a coder)...but Iove to make things. We're pretty proud of the final build....pretty much completely to spec based on your instructions. I was wondering if there would be a way to have this build "double" as a "Simon" game....without changing any of the internal components (as they are all hot glued). I've seen several "simon" arduino projects, but they have a different build. I'm not a coder, so if anyone has any suggestions on how to make this work, i'd love to spend some time learning how to do it.

    arduino project.jpg
    3 replies
    0
    None
    IronRingChrisL70

    Reply 6 months ago

    You’re in luck, I did code in Simon, just never pushed it to the master branch on github. Go download the code from the ‘simon’ branch and you’ll have both games at once on the arduino.

    0
    None
    ChrisL70IronRing

    Reply 6 months ago

    fantastic...but i'm having an issue. I downloaded the files from the Branch in Github, however there is no "ino" file and therefore I can't figure out how to load the project into Arduino IDE (or PlatformIO) and compile/upload to Arduino. Arduino IDE simply wont load without the ino file. PlatformIO loads the project, but I get errors when compiling. I'm probably missing something (<-- Newbie)...and hoping for some direction. Thanks.

    0
    None
    ChrisL70ChrisL70

    Reply 6 months ago

    For any other newbies out there, I figured this out.
    1. Go to the github location (specified above) and change the dropdown list that says "master" to "simon". Download those files and unzip.
    2. Use the aforementioned program PlatformIO (not Arduino IDE). You do need Arduino IDE installed however so that you can point to it's "libraries" file folder later on. See this guide to get PlatformIO installed and add the Platform IDE Package setup - https://docs.platformio.org/en/latest/ide/vscode.html

    3. Now in PlatformIO you should have an alien icon (Platform IDE). Click the Alien and then start "New Project". This will create a basic file structure for your build.
    4. In Platform IDE go to the "Libraries" button (this will open the PlatformIO Library search engine. Search for "LiquidCrystal". A few will show up....choose the "LiquidCrystal by Arduino"" version. Click the 3 dots beside "Install" and choose "Install to". Scroll down and click "Install". This will copy the library into the PlatformIO directory for automatic call up of that library later on.
    5. Go back to the "simon" folder you previously downloaded from Github, copy all the files inside that folder and paste them within the file structure window within your PlatformIO project. Let them overwrite any identical files/folders.
    6. Delete file "main.cpp"
    7. Rename the "fastest.cpp" file to "main.cpp"
    8. Click on the platform.ini file to view the code. Line 12 ("lib_dir=) should point to the Arduino "libraries" folder (from you Arduino IDE install directory).
    9. Also in platform.ini you need to tell it what board you are using. I was using Arduino Uno, so changed everything like so:
    ; [env:uno]
    ; platform=atmelavr
    ; board=uno
    ; framework=arduino

    ;[env:uno]
    ;platform=atmelavr
    ;board=uno
    ;framework=arduino


    [env:uno]
    platform = atmelavr
    board = uno
    framework = arduino
    10. Build/Compile
    11. Upload to your Arduino project

    This worked for me. You lose the ability in the Reaction game to choose between "light only/sound only/light and sound", but you gain the ability to choose either the Simon Game or the Reaction Game. Still get Reaction Game high scores,etc/

    I'm never programmed, nor am I familiar with these programs ...so took me a while to figure all this stuff out. Still might not be the best explanation above, but should help if anyone else is in the same boat. Was a fun project to build and thanks again to IronRing for the build!
    0
    None
    VitH4

    2 years ago

    Hello IronRing, thanks so much for sharing your project here! It was so inspiring for me so much that I decided to make the game too :-) My family loves it! And If I may, I would like to show you the outcome of my exertion :-) Here it is -

    https://www.youtube.com/watch?v=XbwiGoXNXZg. Thanks again and best regards! Vit

    3 replies
    0
    None
    IronRingVitH4

    Reply 1 year ago

    Nice build, thanks for sharing. A link back on your youtube video with credit to this project would be appreciated.

    0
    None
    ChrisL70VitH4

    Reply 6 months ago

    Hi There, Beautiful build! Wondering if you could post the Schematic (or pictures of the internals) and the code for this build? Would love to learn how to integrate the additional audio and scoring in the future.

    0
    None
    23nashbs

    7 months ago

    Hey, i was having quite some trouble with the code. I'm not quite too sure that the #include at the very beginning is and what to do with it. It seems to not be working with my Arduino. If you could help we with this problem it would be wonderful.

    1 reply
    0
    None
    IronRing23nashbs

    Reply 7 months ago

    Hi, you shouldn't need to change or do anything to the code - the directions I provided should put the code on your UNO or NANO

    0
    None
    bikeman2

    1 year ago

    We solved the problem this morning. We replaced the pot and it worked, we were stoked. When we get the project finished I will post pictures.

    0
    None
    bikeman2

    1 year ago

    Hello Iron Ring, this looks like a great game. Would like some help if you could. I am a HS teacher and I have a student building this, just without the IC 595 chip. Everything seems to work the way it should except we don't get text readout on the LCD screen. It has backlight. Any help would be appreciated.

    1 reply
    0
    None
    IronRingbikeman2

    Reply 1 year ago

    Cool, please post a picture of the completed project! Have you tried adjusting the contrast potentiometer? It controls how bright the text is. If set too far one way it will be blank.