Millis() is Not Working

I have a sketch that uses two timers using millis() from a library I created to keep time. The timers seem to be working correctly, but when I print the start time of each timer, it is clearly wrong.

E.g. the timer is set to run for 3 seconds. When I start the timer the first time, it reads that it started at 0. The next time I start the timer, right after it has finished running once, it reads that it started at 2 seconds. This should not be possible.

I have even tried timing it on my phone, and have seen the timerStart value read 5 seconds, when the sketch has been running for 10.

Does anyone have any idea what could be going wrong? Code below.

Here is the library’s .h file:

#ifndef Timer_h
#define Timer_h

#include <Arduino.h>

class Timer {
    Timer(unsigned long timerLength);
    unsigned long timerStart;
    unsigned long timeElapsed;
    boolean isFinished = true;
    boolean timerStarted = false;
    void startTimer();
    void checkTimer();
    unsigned long _timerLength;


Here is the library’s .cpp file:

#include <Arduino.h>
#include <Timer.h>

Timer::Timer(unsigned long timerLength) {
  _timerLength = timerLength;  

void Timer::startTimer() {
  if (!timerStarted) {
    timerStart = millis();
    timerStarted = true;

void Timer::checkTimer() {
  timeElapsed = millis() - timerStart;
  if (timeElapsed >= _timerLength) {
    isFinished = true;
    timerStarted = false;
  } else {
    isFinished = false;

And here is part of my sketch code, where the timerStart value is wrong:

#include <Timer.h>

Timer breathTimer(3000);
Timer betweenTimer(1000);

// this part determines if a turbine is spinning or not
  uint8_t x = digitalRead(FLOWSENSORPIN);

  //if the turbine is spinning
  if (x == HIGH) {

    //start the breath timer
    if (betweenTimer.isFinished) {
      if (breathTimer.isFinished) {
        Serial.print("Breath Timer Started @ ");

void setup() {
   digitalWrite(FLOWSENSORPIN, HIGH);
   betweenTimer.isFinished = true;

void loop() { 

  // check the breath timer
  if (breathTimer.timerStarted) {
    if (breathTimer.isFinished) {
      Serial.println("Breath Timer is Finished");
      Serial.println("Between Timer Started");

  if (betweenTimer.timerStarted) {
    if (betweenTimer.isFinished) {
      Serial.println("Between Timer is Finished");

And here is part of my sketch code

Why only part? What is causing this trouble could be elsewhere in your code.

Why are you messing with Timer0 interrupt vectors, and using deprecated interrupt macros?