Stopwatch for fire sport via Arduino


  • The firefighting team has every village or part of the city.
  • Village weekly competitions are held every week, especially in the summer, and teams score valuable points, achievements and failures that are decided by hundredths or thousandths of a second.
  • The stopwatch uses millis, an internal Arduino timer that returns the number of milliseconds since the processor starts.
  • Thus, we can measure time to 3 decimal places (1000 ms = 1 second).
  • The system logic is executed every millisecond!
  • System functionality
  • The stopwatch is started with the button, the second button can be used to reset the time.
  • Two switch contacts located on the targets are activated when the target falls, the left / right stopwatch current stops.
  • (Part of the time system logic)

  • (Data sent to display on line)
  • What does the project use after the technical (hardware) project page?
  • Arduino, or standalone AtMega chip
  • 16x2 or 20x4 LCD display with I2C converter
  • Two buttons
  • Two switching contacts
  • Stopwatch in action:

    Stopwatch logic - to tenths - can be edited for your project in thousandths


    #include <Wire.h>
    #include <LiquidCrystal_I2C.h>
    LiquidCrystal_I2C lcd(0x27, 16, 2); //I2C adresa, stlpce, riadky, pouziva sa i 0x3F pre displej
    const int spustacresettlacidlo = 12;
    unsigned long lastPressedspustacresettlacidlo = 0; //berie cas z millisu - unsigned long
    boolean run = false;         //bezi cas?
    int spustacresettlacidloState = HIGH;
    int spustacresettlacidloCurrState = HIGH;
    long timer = 0; //The timer
    int second = 0;
    int minute = 0;
    int tenth = 0;
    void setup() {
      lcd.begin();
      lcd.backlight();
      pinMode(spustacresettlacidlo, INPUT_PULLUP);
      lcd.setCursor(0, 0);
      lcd.print("00:00:0");
    }
    
    void tickClock() {
      Serial.println(millis() / 10);
      if ((timer - millis() / 100) >= 100 || timer == 0) {
        tick();
        timer = millis() / 100;
      }
    }
    
    void loop() {
      tickClock();
      spustacresettlacidloState = digitalRead(spustacresettlacidlo);
      checkStart();
    }
    
    void checkStart() {
      if (spustacresettlacidloState != spustacresettlacidloCurrState) {
        if (spustacresettlacidloState == LOW && (millis() - lastPressedspustacresettlacidlo) > 100 || lastPressedspustacresettlacidlo == 1) {
          lastPressedspustacresettlacidlo = millis();
          run = !run;
        }
      }
      spustacresettlacidloCurrState = spustacresettlacidloState;
    }
    
    
    void tick() {
      if (run) {
        updateLCD();
        if (tenth == 9) {
          tenth = 0;
          if (second == 59) {
            second = 0;
            minute++;
          } else {
            second++;
          }
        } else {
          tenth++;
        }
      }
    }
    
    void updateLCD() {
      lcd.setCursor(0, 0);
      if (minute < 10) {
        lcd.print("0");
      }
      lcd.print(minute, DEC);
      lcd.print(":");
      if (second < 10) {
        lcd.print("0");
      }
      lcd.print(second, DEC);
      lcd.print(":");
      lcd.print(tenth, DEC);
    }
    

    Lib (I2C) pre LCD 16x2, 20x4

    Scheme: