Int declarations

Hi awol, have annotated some of the more relevant lines of code. It's simply an exercise in setting a timer, that a code can terminate the timer. You can set the code and select the time you want. Once the timer is counting, you can press * and enter the code for it to stop.

#include <LiquidCrystal.h>
#include <Keypad.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(32, 34, 36, 38, 40, 42);

int Scount = 01; // count seconds
int Mcount = 00; // count minutes
int Hcount = 00; // count hours
long secMillis = 0; // store last time for second add
long interval = 1000; // interval for seconds
char password[6]; // number of characters in our password
int currentLength = 0; //defines which number we are currently writing for reset code
int currentLength2 = 0; //defines which number we are currently writing for selecting time
char entered[6]; //This keep track of what is entered for the code

void setup() {
lcd.cursor();
lcd.setCursor(0,0);
lcd.print("Select Time:");
lcd.setCursor(0,0);
lcd.print("1(35) 2(40) 3(45)"); // Select 1 for 35 mins etc
delay(1000);

//Code Input Array for 1 numbers

while (currentLength2 <1) // I am using this to ensure that only 1 press is detected
{
lcd.setCursor(currentLength2, 1);
lcd.cursor();
char key3 = customKeypad.getKey(); // This is my call for detecting what is pressed
key3 == NO_KEY;
if (key3 != NO_KEY)
{
if (key3 == '1'){ //So if '1' is pressed on the kepad
int Hcount=00; // I want to set the global Hour Count to 0
int Mcount=35; // and the minute count to 35.
delay(500); //I did have an lcd.print(Mcount)
}
else //if '1' isn't pressed
if (key3 == '2') { // if '2' is pressed
int Hcount=00;
int Mcount=40;
delay(500);
}
else
if (key3 == '3') { //and if 3 is pressed
int Hcount=00;
int Mcount=45;
delay(500);
}

void loop()
{

timer(); //This calls the timer countdown

char key2 = customKeypad.getKey(); // get the key input for the countdown code.

if (key2 == '*')
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Code: "); //ready for code input

while (currentLength < 6)
{

timer();

char key2 = customKeypad.getKey();
if (key2 == '#')
{
currentLength = 0;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Code: ");
}
else
if (key2 != NO_KEY)
{

lcd.setCursor(currentLength + 7, 0);
lcd.cursor();

lcd.print(key2);

entered[currentLength] = key2; // Array to keep track of the 6 digit code
currentLength++;
delay(100);
lcd.noCursor();
lcd.setCursor(currentLength + 6, 0);
lcd.print("*");
lcd.setCursor(currentLength + 7, 0);
lcd.cursor();
}
}

if (currentLength == 6)
{
if (entered[0] == password[0] && entered[1] == password[1] && entered[2] == password[2] && entered[3] == password[3]&& entered[4] == password[4]&& entered[5] == password[5])
{
lcd.noCursor();
lcd.clear();
lcd.home();
lcd.print("Timer stopped. Reset?");
currentLength = 0;
digitalWrite(ledPin2,HIGH); //Switch Off Green Part of LED
digitalWrite(ledPin6,LOW); //Switch Off Green Part of LED
digitalWrite(ledPin2,LOW); //Switch Off Green Part of LED
digitalWrite(ledPin6,LOW); //Switch Off Green Part of LED
delay(2500);
}
else
{
lcd.noCursor();
lcd.clear();
lcd.home();
lcd.print("Wrong Code!");

if (Hcount > 0)
{
Hcount = Hcount - 1;
}

if (Mcount > 0)
{
Mcount = Mcount - 59;
}
if (Scount > 0)
{
Scount = Scount - 59;
}
delay(1500);
currentLength = 0;

}
}
}
}

void timer() //Start the Timer countdown
{

unsigned char i;
if (Hcount <= 0)
{
if ( Mcount < 0 )
{
lcd.noCursor();
lcd.clear();
lcd.home();
lcd.print("Timer Completed! ");

///Show RED LED
digitalWrite(ledPin2,LOW); //Switch Off Green Part of LED
digitalWrite(ledPin3,HIGH); // switch On Red Part of LED
digitalWrite(ledPin4,LOW); // switch on LED
digitalWrite(ledPin5,HIGH); // switch on LED
digitalWrite(ledPin6,HIGH); // switch on LED

while (Mcount < 0)
{
currentLength = 0;
// digitalWrite(ledPin3, HIGH);
delay(2500);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Reset timer");
currentLength = 0;
}
}
}

lcd.setCursor (0,1); // sets cursor to 2nd line
lcd.print ("Timer:");

if (Hcount >= 10)
{
lcd.setCursor (7,1);
lcd.print (Hcount);
}
if (Hcount < 10)
{
lcd.setCursor (7,1);
lcd.write ("0");
lcd.setCursor (8,1);
lcd.print (Hcount);
}

lcd.print (":");

if (Mcount >= 10)
{
lcd.setCursor (10,1);
lcd.print (Mcount);
}
if (Mcount < 10)
{
lcd.setCursor (10,1);
lcd.write ("0");
lcd.setCursor (11,1);
lcd.print (Mcount);

}
if (Mcount < 1)
{
lcd.setCursor (10,1);
lcd.write ("0");
lcd.setCursor (11,1);
lcd.print (Mcount);

}
lcd.print (":");

if (Scount >= 10)
{
lcd.setCursor (13,1);
lcd.print (Scount);
}
if (Scount < 10)
{
lcd.setCursor (13,1);
lcd.write ("0");
lcd.setCursor (14,1);
lcd.print (Scount);
}

if (Hcount <0)
{
Hcount = 0;
}

if (Mcount <0)
{
Hcount --;
Mcount = 59;
}

if (Scount <1) // if 60 do this operation
{
Mcount --; // add 1 to Mcount
Scount = 59; // reset Scount
}

if (Scount > 0) // do this oper. 59 times
{
unsigned long currentMillis = millis();

if(currentMillis - secMillis > interval)
{

secMillis = currentMillis;
Scount --; // add 1 to Scount

{
digitalWrite(ledPin2,HIGH); // switch on LED
delay(200); // wait for one second
digitalWrite(ledPin2,LOW); // switch off LED
}
}
}
}