Can't get timer code to display

Hey, I’m very new to Arduino and this is my first medium project. I am trying to make an LCD display a countdown timer that can be reset with a button, and a period counter that goes up by one every time you press it for games. When I run my code the Period counter works, but the timer doesn’t. Anyone have any ideas?

#include <SimpleTimer.h>
#include <LiquidCrystal_I2C.h>


const int ButtonPin = 2;
const int ButtonPin2 = 4;
int buttonInfo;
int buttonInfo2;
int Period;
int OldP;
int seconds = 10;
int minutes = 10;
int timeOverflowFix = 59;

SimpleTimer timer;

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {


  pinMode(ButtonPin, INPUT);
  pinMode(ButtonPin2, INPUT);
  lcd.begin();

}

void repeatMe() {

  seconds--;
  if (seconds == 0) {
    seconds + timeOverflowFix == seconds;
    minutes--;

  }

}

void loop() {

  buttonInfo = digitalRead(ButtonPin);

  if (buttonInfo != OldP) {

    if (buttonInfo == HIGH) {

      Period++;

    } else {

    }

    delay(50);

  }

  OldP = buttonInfo;

  lcd.setCursor(12, 1);
  lcd.print("P: ");
  lcd.setCursor(14, 1);
  lcd.print(Period);
  lcd.setCursor(11, 0);
  lcd.print(minutes);
  lcd.print(":");
  lcd.print(seconds);

  timer.setInterval(1000, repeatMe);

  buttonInfo2 = digitalRead(ButtonPin2);

  if (buttonInfo2 == HIGH) {

    timer.toggle(repeatMe);
    delay(50);

  }

}

You have posted code without using code tags. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don’t do it, some of the character sequences in the code can be misinterpred by the forum code as italics or funny emoticons. The “Code: [Select]” feature allows someone to select the entire sketch so it can be easily copied and pasted into the IDE for testing.
If you have already posted without using code tags, open your message and select “modify” from the pull down menu labelled, “More”, at the lower right corner of the message. Highlight your code by selecting it (it turns blue), and then click on the “</>” icon at the upper left hand corner. Click on the “Save” button. Code tags can also be inserted manually in the forum text using the code and /code metatags.

Before you do any of that, REMOVE ALL the useless blank lines between your code lines and do an auto format in the IDE using ctrl-T.

aarg:
You have posted code without using code tags. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don’t do it, some of the character sequences in the code can be misinterpred by the forum code as italics or funny emoticons. The “Code: [Select]” feature allows someone to select the entire sketch so it can be easily copied and pasted into the IDE for testing.
If you have already posted without using code tags, open your message and select “modify” from the pull down menu labelled, “More”, at the lower right corner of the message. Highlight your code by selecting it (it turns blue), and then click on the “</>” icon at the upper left hand corner. Click on the “Save” button. Code tags can also be inserted manually in the forum text using the code and /code metatags.

Before you do any of that, REMOVE ALL the useless blank lines between your code lines and do an auto format in the IDE using ctrl-T.

I did it.

You have this line in loop():

  timer.setInterval(1000, repeatMe);

I think that must be wrong. You should not be repeatedly setting up the callback function…

Here is an example from the library docs:

void setup() {
    Serial.begin(9600);
    timer.setInterval(1000, repeatMe);
}

What is this supposed to do:

seconds + timeOverflowFix == seconds;

I would suggest getting a different screen and I could help you with that and the looks nicer.

[/quote]

aarg:
You have this line in loop():

  timer.setInterval(1000, repeatMe);

I think that must be wrong. You should not be repeatedly setting up the callback function…

Here is an example from the library docs:

void setup() {

Serial.begin(9600);
    timer.setInterval(1000, repeatMe);
}

noticed that and changed it to this

#include <SimpleTimer.h>
#include <LiquidCrystal_I2C.h>

const int ButtonPin = 2;
const int ButtonPin2 = 4;
int buttonInfo; 
int buttonInfo2;
int Period;
int OldP;
int seconds = 10;
int minutes = 10;
int timeOverflowFix = 59;
SimpleTimer timer;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
  pinMode(ButtonPin, INPUT);
  lcd.begin();
  timer.setInterval(1000, repeatMe);
  timer.disable(repeatMe);
}

void repeatMe() {
  lcd.clear();
  seconds--;
  if (seconds == 0) {
    seconds + timeOverflowFix == seconds;
    minutes--;
  }
}
void loop() {
  buttonInfo = digitalRead(ButtonPin);
  buttonInfo2 = digitalRead(ButtonPin2);
  if (buttonInfo != OldP) {
    if (buttonInfo == HIGH) {
      Period++;
    } else {
    }
    delay(50);
  }
  OldP = buttonInfo;
  lcd.setCursor(12, 1);
  lcd.print("P: ");
  lcd.setCursor(14, 1);
  lcd.print(Period);
  lcd.setCursor(11, 0);
  lcd.print(minutes);
  lcd.print(":");
  lcd.print(seconds);
  if (buttonInfo2 == HIGH) {
    timer.toggle(repeatMe);
    delay(50);
  }
}

larryd:
What is this supposed to do:

seconds + timeOverflowFix == seconds;

seconds + timeOverflowFix == seconds is to add 59 to seconds because timeOverflowFix = 59.
I need this because when seconds hit 0 it resets the seconds and then subtracts one from the minutes.

Your syntax is wrong.

dwertleplayz:
seconds + timeOverflowFix == seconds is to add 59 to seconds because timeOverflowFix = 59.
I need this because when seconds hit 0 it resets the seconds and then subtracts one from the minutes.

Unfortunately for you, that is not what it does. It evaluates the comparison statement 'seconds + timeOverflowFix == seconds' to true or false, and then discards the result without assigning it to any variable.

aarg:
Unfortunately for you, that is not what it does. It evaluates the comparison statement 'seconds + timeOverflowFix == seconds' to true or false, and then discards the result without assigning it to any variable.

how would I make it do what I want?

dwertleplayz:
seconds + timeOverflowFix == seconds is to add 59 to seconds because timeOverflowFix = 59.
I need this because when seconds hit 0 it resets the seconds and then subtracts one from the minutes.

seconds += 59;

There should not be a "timeOverflowFix". Something is wrong!