reset timer

i have this program for i need to reset the time after the pins goes low then high again.. ive read alot from the other references and they provide with fixes w/c i cant understand im only an amatuer at programming and still lacking alot can someone pls help me in trying to put reset in this program... i am using millis()

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int minute = 0;
int seconds =0;
int hrs = 0;
unsigned long currentmillis = 0;
long previousmillis = 0;
long interval = 12000;
const int switch1 = A0;

void setup()
{
lcd.begin(20,4);
pinMode (switch1,INPUT);
}
void loop()
{

if (digitalRead(switch1) == HIGH)
{
currentmillis = millis();

if(currentmillis - previousmillis > interval)
{
previousmillis = currentmillis;
++minute;
if(minute == 11)
{
++hrs;
minute = 0;
}
seconds = 0;
}
seconds = ((currentmillis-previousmillis)/1000);
}
if(digitalRead(switch1) == LOW)
{
seconds = 0;

lcd.setCursor(0,2);
lcd.print("hr: ");
lcd.print(hrs);
lcd.print(" mn: ");
lcd.print(minute);
lcd.print(" sc: ");
lcd.print(seconds);
lcd.print(" ");

}

Please don't post code (incorrectly) that won't compile. It wastes everyone's time.

i have this program for i need to reset the time after the pins goes low then high again.

After what pin(s) go LOW then HIGH again?

Reset what time?

not in a rude way to tell sir but the program is working... and at 12 seconds the minute adds 1 and at 11 mins the hrs add 1 and so on... for the pin i am using AO as the indicator switch... its currently displaying at the lcd.. my problem is to reset it at O seconds O mins O hrs ive managed to make the mins and hrs O but since the seconds is based on currentmillis which is = to millis() if i put the switch at high again it jumps the number O and goes equally to the currentmillis value...

Paul is right, the code you posted doesn't compile. You have a missing closing brace '}'.

oh im really sorry about this the one i pasted was my previous sketch

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int minute = 0;
int seconds =0;
int hrs = 0;
unsigned long currentmillis = 0;
long previousmillis = 0;
long interval = 12000;
const int switch1 = A0;

void setup()
{
lcd.begin(20,4);
pinMode (switch1,INPUT);
lcd.setCursor(0,2);
lcd.print("hrs: ");
lcd.setCursor(6,2);
lcd.print(" min: ");
lcd.setCursor(13,2);
lcd.print(" sec: ");
}
void loop()
{

currentmillis = millis();

if(currentmillis - previousmillis > interval)
{
previousmillis = currentmillis;
++minute;
if(minute == 11)
{
++hrs;
minute = 0;
}
seconds = 0;
}
seconds = ((currentmillis-previousmillis)/1000);

if (digitalRead (switch1) == HIGH)
{
lcd.setCursor(4,2);
lcd.print(hrs);
lcd.print(" ");
lcd.setCursor(11,2);
lcd.print(minute);
lcd.print(" ");
lcd.setCursor(18,2);
lcd.print(seconds);
lcd.print(" ");
}
else
{
hrs = 0;
minute =0;

}

}

this one is the one working correctly and i am troubleshooting right now. im really sorry about the error got mixed up with the file

++minute;
if(minute == 11)
{
++hrs;
minute = 0;

No wonder time flies. 10 minute hours?

im only using those variables so that i can test the following...

the positioning of the displays in the lcd
the change of the state of minutes and hrs

if i fix the seconds then i can change the values to 60000 for the interval and 60 for the minute interval

It still isn't clear, to me at least, what timer you want to reset. You can not reset millis().

if(currentmillis - previousmillis > interval)
{
  previousmillis = currentmillis;
  ++minute;
  if(minute == 11)
  {
    ++hrs;
    minute = 0;
  } 
  seconds = 0;
}
seconds = ((currentmillis-previousmillis)/1000);

If the if test evaluates to true, the time it takes to execute the code in the if block is on the order of about 500 nanoseconds. The difference between currentmillis and previousmillis will still be 0, so seconds will be 0 when the if block ends.

Maybe what you need to do is add

  previousmillis = currentmillis;

to

else
  {
    hrs = 0;
    minute =0;
   
  }

PS. There is a really neat tool in the IDE - Tools + Auto format. Give it a try. We'll like it.

PPS. There is a icon above the text entry are with a # on it. Use that when posting code, please.

thx for the comments..the seconds that is what i want to reset.. but it is somewhat connected too much to the millis() when switch is high i want to start the seconds to 0 but what happens is the seconds value is directly connected to the currentmillis - previousmillis which limits the value from 1 to 12 so if i put the switch in high instead of 0 the value between 1 to 12 appears as the value of the seconds continuing the count until it resets again to zero...

So, in the reset block, set previousmillis to millis(). When the code resumes after the switch is released, seconds will take on the current difference (0) not the length of time the switch was held down.

and it worked like a charm thx.. the was the only command left i didnt put... thank you very much i learned alot