user55873: So I have a circuit for a timer (I don't think it is the problem)

Sorry for it being a little messy.
And I have this code (probably the problem):
// LiquidCrystal - Version: Latest 
#include <LiquidCrystal.h>

/*

*/


const int switchUnitButton = 9;
const int selectButton = 10;
const int startButton = 8;
const int stopButton = 7;
const int d4 = 5;
const int d5 = 4;
const int d6 = 3;
const int d7 = 2;
const int rs = 12;
const int en = 11;
String unit = "sec";
int unitCycle = 1;
int secCount = 0;
int minCount = 0;
int hourCount = 0;
int dayCount = 0;
int switchUnitState;
int prevUnitState;
int selectState;
int prevSelectState;
int startState;
int prevStartState;
int stopState;
int prevStopState;
LiquidCrystal lcd = LiquidCrystal(rs, en, d4, d5, d6, d7);

void setup() {
  Serial.begin(9600);
  pinMode(switchUnitButton, INPUT);
  pinMode(selectButton, INPUT);
  pinMode(startButton, INPUT);
  pinMode(stopButton, INPUT);
  lcd.begin(16, 2);
  lcd.clear();
}

void loop() {

  switchUnitState = digitalRead(switchUnitButton);
  selectState = digitalRead(selectButton);
  startState = digitalRead(startButton);
  stopState = digitalRead(stopButton);

  if (switchUnitState == HIGH) {
    if (prevUnitState != switchUnitState) {
      if (unitCycle < 4) {
       unitCycle++;
      } else if (unitCycle == 4) {
       unitCycle = 1;
      }    
    }
  }

  Serial.print(unitCycle + "\n");

  if (unitCycle == 1) {
    unit = "sec";
  } else if (unitCycle == 2) {
    unit = "min";
  } else if (unitCycle == 3) {
    unit = "hour";
  } else {
    unit = "day";
  }

  Serial.print(unit + "\n");

  if (selectState == HIGH) {
    if (prevSelectState != selectState) {
      if (unit == "day") {
        dayCount++;
      } else if (unit == "sec") {
        secCount++;
      } else if (unit == "hour") {
        hourCount++;
      } else if (unit == "min") {
        minCount++;
      }
    }
  }

  lcd.setCursor(0, 0);
  lcd.print("Sec: " + String(secCount) + " Min: " + String(minCount));
  lcd.setCursor(0, 1);
  lcd.print("Hr: " + String(hourCount) + " Day: " + String(dayCount));

  prevUnitState = switchUnitState;
  prevSelectState = selectState;
  prevStartState = startState;
  prevStopState = stopState;
}

And sometimes without me clicking a button the unit value changes or sometimes when I click the selectButton for the amount to go up it changes which unit it is adding to. And sometimes the string has parts before it from other units like "inhour" what is happening?

user4143: You are seriously abusing the String class.  There is absolutely no need to use any Strings at all in your program.
For example:
  if (unitCycle == 1) {
    unit = "sec";
  } else if (unitCycle == 2) {
    unit = "min";
  } else if (unitCycle == 3) {
    unit = "hour";
  } else {
    unit = "day";
  }

  Serial.print(unit + "\n");

would be better written as:
  if (unitCycle == 1) {
    Serial.println(F("sec"));
  } else if (unitCycle == 2) {
    Serial.println(F("min"));
  } else if (unitCycle == 3) {
    Serial.println(F("hour"));
  } else {
    Serial.println(F("day"));
  }

And:
  if (selectState == HIGH) {
    if (prevSelectState != selectState) {
      if (unit == "day") {
        dayCount++;
      } else if (unit == "sec") {
        secCount++;
      } else if (unit == "hour") {
        hourCount++;
      } else if (unit == "min") {
        minCount++;
      }
    }
  }

as:
  if (selectState == HIGH) {
    if (prevSelectState != selectState) {
      if (unitCycle == 1) {
        secCount++;
      } else if (unitCycle == 2) {
        minCount++;
      } else if (unitCycle == 3) {
        hourCount++;
      } else {
        dayCount++;
      }
    }
  }

And then the cardinal sin:
lcd.print("Sec: " + String(secCount) + " Min: " + String(minCount));

All that string creation, concatenation, and destruction is just evil.  Instead, use:
lcd.print(F("Sec: "));
lcd.print(secCount);
lcd.print(F(" Min: "));
lcd.print(minCount);


55873: <p>So I have a circuit for a timer (I don't think it is the problem)</p>

<p><a href="https://i.stack.imgur.com/lUq3o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lUq3o.png" alt="enter image description here"></a></p>

<p>Sorry for it being a little messy.</p>

<p>And I have this code (probably the problem):</p>

<pre><code>// LiquidCrystal - Version: Latest 
#include &lt;LiquidCrystal.h&gt;

/*

*/


const int switchUnitButton = 9;
const int selectButton = 10;
const int startButton = 8;
const int stopButton = 7;
const int d4 = 5;
const int d5 = 4;
const int d6 = 3;
const int d7 = 2;
const int rs = 12;
const int en = 11;
String unit = "sec";
int unitCycle = 1;
int secCount = 0;
int minCount = 0;
int hourCount = 0;
int dayCount = 0;
int switchUnitState;
int prevUnitState;
int selectState;
int prevSelectState;
int startState;
int prevStartState;
int stopState;
int prevStopState;
LiquidCrystal lcd = LiquidCrystal(rs, en, d4, d5, d6, d7);

void setup() {
  Serial.begin(9600);
  pinMode(switchUnitButton, INPUT);
  pinMode(selectButton, INPUT);
  pinMode(startButton, INPUT);
  pinMode(stopButton, INPUT);
  lcd.begin(16, 2);
  lcd.clear();
}

void loop() {

  switchUnitState = digitalRead(switchUnitButton);
  selectState = digitalRead(selectButton);
  startState = digitalRead(startButton);
  stopState = digitalRead(stopButton);

  if (switchUnitState == HIGH) {
    if (prevUnitState != switchUnitState) {
      if (unitCycle &lt; 4) {
       unitCycle++;
      } else if (unitCycle == 4) {
       unitCycle = 1;
      }    
    }
  }

  Serial.print(unitCycle + "\n");

  if (unitCycle == 1) {
    unit = "sec";
  } else if (unitCycle == 2) {
    unit = "min";
  } else if (unitCycle == 3) {
    unit = "hour";
  } else {
    unit = "day";
  }

  Serial.print(unit + "\n");

  if (selectState == HIGH) {
    if (prevSelectState != selectState) {
      if (unit == "day") {
        dayCount++;
      } else if (unit == "sec") {
        secCount++;
      } else if (unit == "hour") {
        hourCount++;
      } else if (unit == "min") {
        minCount++;
      }
    }
  }

  lcd.setCursor(0, 0);
  lcd.print("Sec: " + String(secCount) + " Min: " + String(minCount));
  lcd.setCursor(0, 1);
  lcd.print("Hr: " + String(hourCount) + " Day: " + String(dayCount));

  prevUnitState = switchUnitState;
  prevSelectState = selectState;
  prevStartState = startState;
  prevStopState = stopState;
}
</code></pre>

<p>And sometimes without me clicking a button the unit value changes or sometimes when I click the selectButton for the amount to go up it changes which unit it is adding to. And sometimes the string has parts before it from other units like "inhour" what is happening?</p>
 4143: <p>You are seriously abusing the String class.  There is absolutely no need to use any Strings at all in your program.</p>

<p>For example:</p>

<pre><code>  if (unitCycle == 1) {
    unit = "sec";
  } else if (unitCycle == 2) {
    unit = "min";
  } else if (unitCycle == 3) {
    unit = "hour";
  } else {
    unit = "day";
  }

  Serial.print(unit + "\n");
</code></pre>

<p>would be better written as:</p>

<pre><code>  if (unitCycle == 1) {
    Serial.println(F("sec"));
  } else if (unitCycle == 2) {
    Serial.println(F("min"));
  } else if (unitCycle == 3) {
    Serial.println(F("hour"));
  } else {
    Serial.println(F("day"));
  }
</code></pre>

<p>And:</p>

<pre><code>  if (selectState == HIGH) {
    if (prevSelectState != selectState) {
      if (unit == "day") {
        dayCount++;
      } else if (unit == "sec") {
        secCount++;
      } else if (unit == "hour") {
        hourCount++;
      } else if (unit == "min") {
        minCount++;
      }
    }
  }
</code></pre>

<p>as:</p>

<pre><code>  if (selectState == HIGH) {
    if (prevSelectState != selectState) {
      if (unitCycle == 1) {
        secCount++;
      } else if (unitCycle == 2) {
        minCount++;
      } else if (unitCycle == 3) {
        hourCount++;
      } else {
        dayCount++;
      }
    }
  }
</code></pre>

<p>And then the cardinal sin:</p>

<pre><code>lcd.print("Sec: " + String(secCount) + " Min: " + String(minCount));
</code></pre>

<p>All that string creation, concatenation, and destruction is just evil.  Instead, use:</p>

<pre><code>lcd.print(F("Sec: "));
lcd.print(secCount);
lcd.print(F(" Min: "));
lcd.print(minCount);
</code></pre>
