Arduino "Reaction Timer" - My Kids Love Playing This

Wait for light - press a button. So simple but so funny. All our family plays the game.

 

Arduino "Reaction Timer" - My Kids Love Playing This

Things used in this project

Hardware components

HARDWARE LIST
1 DFRobot I2C 16x2 Arduino LCD Display Module
2 LED (generic)
1 Slide Switch
2 Resistor 10k ohm
1 Battery Holder, 3 x AAA
1 Arduino Micro
2 SparkFun Pushbutton switch 12mm

Hand tools and fabrication machines

 

Soldering iron (generic)

Story

 

I discovered the code somewhere on the Internet and tried it.

All my family loved the game and I decided to assemble it in a funny case to be able to play.

The work is now finished and it is into the hands of my kids.

It is a very basic project but in a kind of case which hides all elements.

Here are some pictures:

This is how it looks. The BIG button is a hit button and the small red one on top is "start"

This is how it looks. The BIG button is a hit button and the small red one on top is "start"

 

I was able to shrink the system and program only an Atmega328P chip. Runs on 3 AAA.

I was able to shrink the system and program only an Atmega328P chip. Runs on 3 AAA.

 

Press Start

Press Start

 

Round 1 of 5

Round 1 of 5

 

Round 2 of 5

Round 2 of 5

 

Average result calculation and showing. The "verdict"

Average result calculation and showing. The "verdict"

Please do not hesitate to ask me questions if needed.

Schematics

 

CODE
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#define btnSTART 5
#define btnHIT 7
#define ledTrigger 9
LiquidCrystal_I2C lcd(0x23,20,4);

void setup() {
  lcd.init(); 
  lcd.backlight();
  pinMode(btnSTART, INPUT_PULLUP);
  pinMode(btnHIT, INPUT_PULLUP);
  pinMode(ledTrigger, OUTPUT);
  digitalWrite(ledTrigger, LOW);
  lcd.print("Salut Famille!");
  delay(2000);
  lcd.clear();
  randomSeed(analogRead(0));
}

void loop() {
  long timeReaction;
  long timeTotal = 0;
  lcd.print("Press START!");
  while (digitalRead(btnSTART)) {}
  delay(10);
  while (!digitalRead(btnSTART)) {}
  lcd.clear();
  lcd.print("Jouez!!!");
  delay(1000);
  for (int i = 0; i < 5; i++) {
    delay(random(500, 5000));
    timeReaction = millis();
    digitalWrite(ledTrigger, HIGH);
    while (digitalRead(btnHIT)) {}
    timeReaction = millis() - timeReaction;
    timeTotal += timeReaction;
    delay(10);
    while (!digitalRead(btnHIT)) {}
    digitalWrite(ledTrigger, LOW);
    lcd.clear();
    lcd.print(i + 1);
    lcd.print(": ");
    lcd.print(timeReaction);
    delay(1000);
  }
  lcd.clear();
  lcd.print("Moyenne = ");
  lcd.print(timeTotal/5);
  delay(10000);
  lcd.clear();
  }

The article was first published in hackster, April 21,  2019

cr: https://www.hackster.io/vinikon/arduino-reaction-timer-my-kids-love-playing-this-bf01ca

author: vinikon

License
All Rights
Reserved
licensBg
0