Keeping Score on a Reaction Timer

I am putting this together for my sister that works at a senior center in town. Two older gentleman are always arguing who still has the fastest reflexes. I put this unit together and gave it to her around Christmas. She says it has become very popular around there with several of the people. I would like to add a new feature, I have experimented a little, but sure if I am on the right track, and I have no idea what I’m doing!

Currently my model works like this…

-Power up
-It echoes “Ernset vs Dennis”
-“Press Button to Start”
-When you press the panel button it runs the loop and echoes “----ready----”
-after a random time (1000-5000ms) is will say “FIRE”
-you hit the remote button, then echoes your time for 4500 ms
-then goes back to “ready” and runs random and goes through “FIRE” again
-this is done three times
-after the third time it breaks the loop and goes all the way to the beginning, “Press Button to Start”

It does everything I wanted it to do.

Now, I want it to remember the 3 scores, then after it cycles the three times, I would like is to display the lowest score, (or all three scores at the same time). Like I said, I have experimented a little and studied several sketches on Github but not sure how to go about this. It is absolutely NOT necessary to save the best score for power cycling as I know the EEPROM has the capabilities of doing. If possible I prefer to know if score can just be held in RAM.

I appreciate and help I can get.


#include <EEPROM.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

int lcdRedPWMPin = 17;
int lcdGreenPWMPin = 16;
int lcdBluePWMPin = 15;
int addr = 0;
byte value;
void setDisplayRGB(int r, int g, int b)

  analogWrite(lcdRedPWMPin,   r);
  analogWrite(lcdGreenPWMPin, g);
  analogWrite(lcdBluePWMPin,  b);

void setup()
  lcd.begin(16, 2);


  pinMode(9, INPUT); //panel button
  digitalWrite(9, HIGH);

  pinMode(8, INPUT); //FIRE button
  digitalWrite(8, HIGH);

  pinMode(10, OUTPUT); //FIRE led
  digitalWrite(10, LOW);
  int    fireButton = digitalRead(8);
  int    panelButton = digitalRead(9);
  setDisplayRGB(100, 100, 75);
  lcd.setCursor(0, 0);
  lcd.print("Ernest vs Dennis");
double timeToFire = 0; //time it took to (fire-trigger)
double fireTimerStarts = millis(); //fire (timer starts)
double triggerTimerStops ; //trigger (timer stops)
int ran; //random

void loop()
  int val = analogRead(0) / 4;

  while (digitalRead(9) == HIGH)
    setDisplayRGB(40, 200, 75); //purple 40,200,75
    lcd.setCursor(0, 0);
    lcd.print("Press Button");
    lcd.setCursor(0, 1);
    lcd.print("to Start ...");
  for (int panelButton = 0; panelButton < 3; panelButton++) {

    lcd.setCursor(0, 0);
    setDisplayRGB(255, 255, 0); //blue
    lcd.print("  ---READY---");
    delay((int)random(1000, 5000));
      ran = random(1, 3);
      if ( ran == 1)
      lcd.setCursor(0, 0);
      setDisplayRGB( 0, 155, 155 );  //red
      lcd.print("     <FIRE>   ");
      digitalWrite(10, HIGH);
      fireTimerStarts = millis();
      while (digitalRead(8) == HIGH)
        triggerTimerStops = millis();
      digitalWrite(10, LOW);
      setDisplayRGB(100, 100, 225); //green
    timeToFire = (triggerTimerStops - fireTimerStarts) / 1000;
      setDisplayRGB(0, 255, 0);
      lcd.setCursor(0, 1);
      lcd.setCursor(11, 1);
      lcd.setCursor(0, 0);
      lcd.print("Your time was ...");

A basic idea. Store each time in it's own global variable (or a single array to hold all 3). Print them to your screen. Then reset them to 0 when it goes to the "press button to start".

Just one idea out of many to follow I'm sure.