If I inserted another coin the time will not add please help me
#include <LiquidCrystal.h>
int Contrast=100;
LiquidCrystal lcd(12, 11, 5, 4, 3, 8);
char timeline[16];
const int coinpin = 2;
const int ledpin = 13;
int relay = 7;
volatile int pulse = 0;
volatile int timer = 0;
long int set1;
long int set2;
long int set3;
long int set4;
long int j;
String hours;
String minutess;
String seconds;
boolean bInserted = false;
void setup()
{
pinMode(relay, OUTPUT);
analogWrite(6,Contrast);
lcd.begin(16, 2);
Serial.begin(9600);
attachInterrupt(digitalPinToInterrupt(coinpin), coinInterrupt, RISING);
pinMode(ledpin, OUTPUT);
lcd.setCursor(3,0);
}
void loop()
{
if( bInserted ){
bInserted = false;
digitalWrite(ledpin, HIGH);
delay(100);
lcd.clear();
Serial.println(timer);
timer= timer + 20;
digitalWrite(relay,LOW);
for(long int j = timer; j >= 0; j--) // this for loopis used to decrease the total time in seconds
{
Serial.println(j);
lcd.setCursor(0,0);
lcd.print("HH:MM:SS");
long int HH = j / 3600; // converting the remaining time into remaining hours
lcd.setCursor(0,1);
Serial.println(HH);
if (HH < 10) { lcd.print('0'); }
lcd.print(HH);
lcd.print(":");
long int MM = (j - (HH*3600))/60 ; //converting the remaining time into remaining minutes
lcd.setCursor(3,1);
Serial.println(MM);
if (MM < 10) { lcd.print('0'); }
lcd.print(MM);
lcd.print(":");
long int SS = j - ((HH3600)+(MM60)); //converting the remaining time into remaining seconds
lcd.setCursor(6,1);
Serial.println(SS);
if (SS < 10) { lcd.print('0'); }
lcd.print(SS);
delay(1000);
if (digitalRead(A3)==1){break;}
if (j == 0)
{
timer = 0;
lcd.clear();
}
}
}
else{
digitalWrite(ledpin, LOW);
digitalWrite(relay,HIGH);
}
lcd.setCursor(0,0);
lcd.print("Insert Coin");
delay(1000);
lcd.clear();
}
void coinInterrupt(){
pulse++ ;
bInserted = true;
}