New to Arduino, looking for/need help with a Timer for 1602 Keypad Display

Hello everyone, I am new to arduino. But of course, I've run into some problems as I am posting here.

I recently purchased this LCD Keypad:

http://www.ebay.com/itm/290946877182?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649

to go on this Arduino:

http://www.ebay.com/itm/171195367635?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649

I've relocated the pins in my programs to (8,9,4,5,6,7), and also checked to see that "yes" - D10 is the bad display on this shield. I've used a Push-The-Buttons program to locate the proper values that work with the LCD buttons. I've also modified some codes I downloaded from the net to basic count-up programs that seem to work well - tho boring and basic.

Now I'm looking to expand on this a little, and something useful for me would be a timer that I can adjust with my pushbuttons. The few I've found searching the internet seem to always have an issue that holds me back (i.e. - need RTC module that I don't have, code shows errors, etc.), I just need something simple I can load and works, once I get it working I can learn a lot from it.

Hi and welcome.

You can do this yourself.
There's a lot to be found, did you actually search for it ?

Assumed you did, did you know you've got a ton of examples to learn from at your fingertips, in IDE ?
Click file - examples - LiquidCrystal and find HelloWorld.
It contains an example that displays Hello World ! on the display and a counter on the second line.
Now combine this with your LCD Key shield and get it displaying that on that.
Then use your buttons to change the values that get printed to the screen.
Tip:
Use buttons to change certain variables, and do some calculation including the counter you now have to get exactly what you want.

And play around a lot with the other examples you find in IDE.
A lot of them don't need extras like a clock or some shield.
A few LEDs and resistors won't harm though.

I have the "Hello World" displaying on my LCD screen, and the counter counting up. That is about as far as I can get. No adjustments can be made with the buttons.

Right.
Because that is what that sketch does.
You said you had the keys working, and had the values that they produce.
Now try to get the display to display that Hello World message, the counter and a value of a key you might be pressing.
This way you are learning, and i guess that is what you want to, right ?

After you have the keys displayed also, think about how you can use those keys to control your counter.
If you have a specific question about that, ask and maybe someone can help you with it.

Mind you, there will be a learning curve that is steep at the start.
To me such things keep it interesting.
Do not expect people to do the coding for you.
But if you have questions, just ask.
There's a lot of help available over here.

OK, I'm sure it looks bad but heres where I am at so far:

[/
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8,9,4,5,6,7);

void setup() 

{
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  }

void loop() 


  {
  lcd.setCursor(12, 1);  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
  
  lcd.noCursor();
  delay(500);
  lcd.cursor();
  delay(500);
  
  int x; // declare variables 
  x = analogRead (0); // assign 'x' to the Arduino's Analogue Inputs (Shield's buttons) 
  lcd.setCursor (0,0);
  lcd.print("LCD Keypad Value");
  
  
  if (x < 1024 && x > 1000)
  lcd.setCursor (0,1);
  {
  lcd.print((analogRead(A0)));
  lcd.print(" NONE");
  }
  
  if (x < 800 && x > 600)
  {
  lcd.clear();
  lcd.setCursor (0,0);
  lcd.print("LCD Keypad Value");
  lcd.setCursor (0,1);
  lcd.print((analogRead(A0)));
  lcd.print(" SELECT");
  delay(1000);
  lcd.clear();
  }
 
 if (x < 600 && x > 400)
  {
  lcd.clear();
  lcd.setCursor (0,0);
  lcd.print("LCD Keypad Value");
  lcd.setCursor (0,1);
  lcd.print((analogRead(A0)));
  lcd.print(" LEFT");
  delay(1000);
  lcd.clear();
  }
  
  if (x < 200 && x > 50)
  {
  lcd.clear();
  lcd.setCursor (0,0);
  lcd.print("LCD Keypad Value");
  lcd.setCursor (0,1);
  lcd.print((analogRead(A0)));
  lcd.print(" UP");
  delay(1000);
  lcd.clear();
  }
  
  if (x < 400 && x > 200)
  {
  lcd.clear();
  lcd.setCursor (0,0);
  lcd.print("LCD Keypad Value");
  lcd.setCursor (0,1);
  lcd.print((analogRead(A0)));
  lcd.print(" DOWN");
  delay(1000);
  lcd.clear();
  }
  
  if (x < 50 && x > -1)
  {
  lcd.clear();
  lcd.setCursor (0,0);
  lcd.print("LCD Keypad Value");
  lcd.setCursor (0,1);
  lcd.print((analogRead(A0)));
  lcd.print(" RIGHT");
  delay(1000);
  lcd.clear();
  }
  
}
code]

Now I am stumped on how to move the cursor, or what name to use, with the keypad.

You are using "delay".
In coding world a delay means "Do absolutely nothing for this amount of milliseconds".
That's a huge waste of time.
It's perfectly normal for you to use delays as you are new to all of this.
But it's still recommended to dump the use of delays as soon as possible.
You can study and play around with the "blink without delay" sketch.
It blinks the on board LED of your Arduino, so you do not need any other components than your board.
And try some more of the examples in that directory (File - Examples), you'll learn from those.

The sketch you have now, prints a text to the screen telling what key has been pressed.
After that, nothing is done with that information.
Consider to register a "left" or 'rigth' (that's what it actually says) key was pressed, and change a variable with that information.
Use that variable to move the cursor.
For starters, keep it simple and just do this, move that cursor and nothing else.

Later on you will learn about reading the actual value of the key that was pressed, because the way it is done now will lead to errors reading the keys.
And indeed there is more to learn, but take it step by step.

Another tip.
As this is all new to you, you'll probably like to use a lot of //comments.
Have them appear all at the same column so they are in line.
That will read a lot easier to you (the IDE doesn't care).

Can someone give me a pointer on getting a cursor to blink without delay, the example is for a pin and checks its state and reverses it if I am correct, I spent several hours and can't put my finger on it how to do this with a LCD cursor.

I'm not looking for the answer, just a pointer or 2.

Thanks

Blink without delay is not about setting a status of some pin.
That is what it does, but the example is about when that is done.

If you want to switch on a lamp for an hour, you can switch on that lamp and watch a stopwatch for 3600 seconds and then switch off.
That would be a blocking code.

You can also switch on that lamp and do some other stuff in the mean time.
While you are doing that other stuff, you'll now and then have a peek at that stopwatch to see whether or not that hour has already passed.
If it did, you can switch off that lamp.
This is a non blocking code, as you were able to do some other stuff besides checking the stopwatch.

Difference here is that in the first case you might be able to have a very exact timing.
In the second case you are looking to see the time has passed already, so that implies you'll always be a bit late.

But i've been talking about hours and seconds here.
You've been talking about milliseconds (that's what 'delay()'is about), a factor 1000 smaller.
The Arduino works in 1/16 of 1/1000 of a millisecond.
That means it can do about 16.000 operations in a millisecond.
And that again means it will not be very far off.

You need to keep track of what you are doing and what has been done (and when).
If you have an other look at the sketch, you should see that this is in there.
Look for the words "current" and "previous", and use those in your sketches too for this goal.
That will help you read your code after a few months and understand what's going on.

kaxx1975:
Can someone give me a pointer on getting a cursor to blink without delay, the example is for a pin and checks its state and reverses it if I am correct, I spent several hours and can't put my finger on it how to do this with a LCD cursor.

Perhaps you had better describe more accurately what you wish to do.

You are I gather, wishing to make the cursor itself blink? So you want to alternately set the cursor on and set it off on the LCD.

You would substitute the command to set the cursor, for the port switch in "Blink without delay".

Can someone give me a pointer on getting a cursor to blink without delay, the example is for a pin and checks its state and reverses it if I am correct, I spent several hours and can't put my finger on it how to do this with a LCD cursor.

I'm not looking for the answer, just a pointer or 2.

There are two things wrong with the approach you posted earlier:

  lcd.noCursor();
  delay(500);
  lcd.cursor();
  delay(500);

First of all you want to use the inherent capability of the HD44780U controller to blink the cursor. This is handled by LiquidCrystal - blink() and noBlink() discussed here http://arduino.cc/en/Tutorial/LiquidCrystalBlink .

Also, for reasons mentioned above, you do not want to use delay(), you want to use the improperly named "Blink Without Delay" technique, which should be called "Blink Without Delay()", discussed here http://arduino.cc/en/Tutorial/BlinkWithoutDelay .

Don

OK, first of all MAS3, I would like to thank you for not "holding my hand" and telling me how to do all of this. You give me just enough info to get me going. I do realize I may be a little ahead of myself in trying to do what I wish to accomplish, therefore I am backing up and going through some of the examples in the arduino software that might pertain to what I wish to accomplish.

Back on topic, I have went through LED blink example (several times). Here is where I am so far (anything after // are my personal notes):

unsigned long previousMillis = 0;
// Start point for the program (gives the program an integer in which to start the first loop(s) of the equation from). This number will change as the program gets rolling. "unsigned long" does not allow a negative number, and long means it can store a larger # than "int" since 1000 per second adds up very rapidly and causes issues with "int"

unsigned long currentMillis = millis();
//keeps track of time non stop since the program started

if(currentMillis - previousMillis >= interval)
//subtracts the stored previousMillis integer from the program run time, when that number becomes greater than the interval I want, execute the following:

previousMillis = currentMillis;
// set the new program run time to the variable "currentMillis"

if (ledState == LOW)
ledState = HIGH;

// On this part, I may be fully understanding, but I am assuming it is checking the current state of the LED (is it on or off right now)
// If it is on, turn it off and vice versa
*please correct me if I am wrong, I do not understand what == means. The only info I can get in google search for "==" is "Is equal to" as opposed to "equals", which I am not fully grasping the meaning of. Google search does not like searching for "==" lol

else

// If the equation (currentMillis - previousMillis >= interval) is not true, do the following:

ledState = LOW;
//keep the LED off

digitalWrite(ledPin, ledState);
//writes the above info to pin 13 for the LED to turn on or off based on equation results.

Now, my problem is I cannot seem to just substitute lcd.cursor(): and lcd.noCursor(); for ledState. I just cannot seem to figure out how to do it. I either get it to blink fully for 3 seconds then off the remainder of the time, off for 3 seconds then on for the remainder, or a non-stop super-fast blink that is almost unnoticeable.

Edit: I set the variable "interval" to 3 seconds (3000)

I know when I figure this out I will probably be smacking my head on how easy it is.....just a little beginner programming issue I'm sure.

OK, now I'm starting to get a little further. I can now move the cursor, and select a number between 0 and 9 per space and keep that number while moving to the next space on the LCD. Took me most of the week to get this far, but things seem to be getting a bit easier as I learn more. If anyone wants to look at this code and offer any suggestions so far, I'm all ears.

[/

#include <LiquidCrystal.h>                                                            // Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);                                                  // My Pin Numbers

int x = 0;      // x position of cursor
int y = 0;      // y position of cursor
int i = 0;      // The Number displayed in the Select Mode (This variable Changes)
int d = 150;    // Delay time for button debounce in Milliseconds (100 = .1 seconds, 1500 = 1.5 Seconds)

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void setup()


{
  lcd.begin(16, 2);
  lcd.setCursor (x, y);

}


void loop()
{
  int b;                                                                              // Declare 'b' variable for button press
  b = analogRead (0);                                                                 // Assign variable 'b' to the Arduino's Analogue Input pin 0 to read the value of resistance


  //------Right, Left, Up, and Down keypad detection and cursor movement mode----------------------------------------------------------------------------------------------------------------------------------------------------------------


  if (b >= 0 && b <= 50)                                                              // Right Button Press. My Pin reading is 0. If Pin 0 reads between 0-50, do this:
  {
    delay(d);                                                                         // Button Debounce (Takes 1 sample of buttonpress for each delay cycle determined by variable 'd' in this statement)
    i = -1;                                                                           // Resets variable "i" to 0, Otherwise "i" will continue from previous state it was in while in the Select Mode below.

    if (x <= 15)                                                                      // Overtravel If Statement. Does not allow the cursor to travel off the screenin the x position. If current position is not greater than 15, do this:
    {
      x = x + 1;                                                                      // Moves the cursor 1 position to the right

      if (x > 15)                                                                     // If x is more than 15, move to beginning of line (x=0 position)
      {
        x = 0;                                                                        // Moves Cursor to beginning of line
      }

    }                                                                                 // End Of Overtravel If Statement

    lcd.setCursor (x, y);                                                             // New Position of cursor
    lcd.cursor();                                                                     // Display Cursor
  }                                                                                   // End of Right Button Press If Statement

  if (b > 50 && b <= 200)                                                             // Up Button Press. My pin reading is 131. If Pin 0 reads between 51-200, do this:
  {
    delay(d);
    i = -1;
    if (y >= 0)
    {
      y = y - 1;
      if (y < 0)
      {
        y = 1;
      }
    }

    lcd.setCursor (x, y);
    lcd.cursor();
  }


  if (b > 200 && b <= 400)                                                            // Down Button Press My Pin reading is 306. If Pin 0 reads between 201-400, do this:
  {
    delay(d);
    i = -1;
    if (y <= 1)
    {
      y = y + 1;

      if (y > 1)
      {
        y = 0;
      }
    }
    lcd.setCursor (x, y);
    lcd.cursor();
  }

  if (b > 400 && b <= 600 )                                                           // Left Button Press. My Pin reading is 479. If Pin 0 reads between 401-600, do this:
  {
    delay(d);
    i = -1;
    if (x >= 0)
    { x = x - 1;
      if (x < 0)                                                                      // If x is more than 15, start again at 0 position
      {
        x = 15;                                                                       // Moves Cursor to end of line
      }
    }
    lcd.setCursor (x, y);
    lcd.cursor();
  }


  //------End Of Right, Left, Up, and Down keypad detection and cursor movement mode---------------------------------------------------------------------------------------------------------------------------------------------------------



  //------SELECT MODE -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  if (b > 600 && b <= 800)                                                           //Select Button Press. My Pin reading is 720. If Pin 0 reads between 601-800, do this:
  {
    delay(d);                                                                        // Button Debounce
    lcd.setCursor (x, y);                                                            // Keep current cursor position
    i = i++;                                                                         // Increments variable "i" by 1. "++i" starts with 1; "i++" starts with 0
    lcd.print(i);                                                                    // Print Value of 'i' Variable
    if (i >= 9) i = -1;                                                              // Always keeps variable "i" between 0 and 9
  }

  //------END OF SELECT MODE-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


  //------If No Button Press Mode------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  if (b > 800 && b <= 1024)                                                          // No Button Press. My Pin reading is 1023. If Pin 0 reads between 801 and 1024, do this:
  {
    lcd.setCursor (x, y);                                                            // Current Cursor Position (No change in position)
    lcd.cursor();                                                                    // Show Cursor
  }

  //------End of If No Button Press statement------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


}                                                                                    //End Of Loop

// Final Goal for this LCD Cursor Movement is to make this a library to hopefully conserve program space. If nothing else it will simplify this to use in other programs that only require numbers

code]

kaxx1975:
I do not understand what == means. The only info I can get in google search for "==" is "Is equal to" as opposed to "equals", which I am not fully grasping the meaning of. Google search does not like searching for "==" lol

OK, "=" is the assignment operator, it means "make (the LHS) equal to (what the RHS evaluates as)".

"==" is one of half a dozen comparison operators, meaning "Is equal to" or "Is it equal to?" or "Does the LHS evaluate to the same as the RHS?" It returns a result for you to use in some way but does not affect either of the values compared.

("LHS" is Left Hand Side, etc.)

Wow, I've learned a lot creating this program and am very excited now!

Button presses move the cursor left right and select the number up and down as I have needed.

Select button starts the timer.

When Timer reaches "00:00:00", it flashes "Times Up" and stops the countdown.

Reset clears if timer has already started (I may change this to use the select button instead)

/*

lcd Countdown Timer

*/

#include <LiquidCrystal.h>                                                            // Initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);                                                  // My Pin Numbers



//------Variables for cursor movement and number selection-----------------------------------------------------------------------------------------------------------------------

int x  = 7;      // x position of cursor
int y  = 1;      // y position of cursor
int i  = 0;      // The Number displayed in the Select Mode (This variable Changes)
int db = 150;    // Delay time for button debounce in Milliseconds (100 = .1 seconds, 1500 = 1.5 Seconds)
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



//------Variables for the formula in the "Start Timer Equation" below, do not change these values!!---------------------------------------
int s = 0;                                       // Used for starting the timer with the select button
int f = 0;                                       // 10's of hours
int e = 0;                                       // 1's of hours
int d = 0;                                       // 10's value of minutes
int c = 0;                                       // 1's value of minutes
int b = 0;                                       // 10's of seconds Value    ( 1000 milli)
int a = 0;                                       // 1's of seconds Value     (10000 milli)
//--------------------------------------------------------------------------------------------------------------------------------------------

void setup()
{
  lcd.begin(16, 2);
  lcd.setCursor (0, 0);
  lcd.print (" Hour Min  Sec");
  lcd.setCursor (1, 1);
  lcd.print(" 00 : 00 : 00");
  lcd.setCursor (x, y);
}

void loop()
{
  int btn;                                                                              // Declare 'b' variable for button press
  btn = analogRead (0);                                                                 // Assign variable 'b' to the Arduino's Analogue Input pin 0 to read the value of resistance
  //------Right button press----------------------------------------------------------------------------------------------------------------------------------------------------------------

  // The following program for Left and Right button press only allow cursor movement to allowed positions, i.e. between the ":" on the display


  if (btn >= 0 && btn <= 50)                                                              // Right Button Press. My Pin reading is 0. If Pin 0 reads between 0-50, do this:
  {
    delay(db);                                                                        // Button Debounce (Takes 1 sample of buttonpress for each delay cycle determined by variable 'd' in this statement)
    // Resets variable "i" to 0, Otherwise "i" will continue from previous state it was in while in the up/down keypad Mode below.
    x = x + 1;                                                                        // Moves the cursor 1 position to the right

    { if (x < 2)                                                                      // If x is less than 2, this keeps the cursor between the ":" on the display
      {
        x = 2;                                                                        // Move cursor directly to 10's of hours position
      }

      if ((x > 3) && (x < 7))                                                         // If x is between 3 and 7, this keeps the cursor between the ":" on the display
      {
        x = 7;                                                                        // Move cursor to 10's of minutes position.
      }

      if ((x > 8) && (x < 12))                                                        // If x is between 8 and 12, this keeps the cursor between the ":" on the display
      {
        x = 12;                                                                       // Move cursor to 10's of seconds position.
      }

      if (x > 13)                                                                     // If x is more than 13, this keeps the cursor between the ":" on the display
      {
        x = 2;                                                                        // Move cursor back to 10's of hours (beginning) position.
      }
    }
    lcd.setCursor (x, y);                                                             // New Position of cursor
    lcd.cursor();                                                                     // Display Cursor
  }

  //------Left Button Press------------------------------------------------------------------------------------

  if (btn > 400 && btn <= 600 )                                                       // Left Button Press. My Pin reading is 479. If Pin 0 reads between 401-600, do this:
  {
    delay(db);
    x = x - 1;
    { if (x < 2)                                                                      // if x is less than 2 position, this keeps the cursor between the ":" on the display
      {
        x = 13;                                                                       // Move cursor to 1's of seconds position.
      }
      if ((x > 3) && (x < 7))                                                         // If x is between 3 and 7, this keeps the cursor between the ":" on the display
      {
        x = 3;                                                                        // Move cursor to 1's of hours position.
      }
      if ((x > 8) && (x < 12))                                                        // If x is between 8 and 12, this keeps the cursor between the ":" on the display
      {
        x = 8;                                                                        // Move cursor to 1's of minutes position.
      }

      if (x > 13)                                                                     // If x is more than 13, this keeps the cursor between the ":" on the display
      {
        x = 12;                                                                       // Move cursor back to 1's of seconds (beginning) position.
      }
    }
  }
  lcd.setCursor (x, y);                                                               // New Position of cursor
  lcd.cursor();                                                                       // Display Cursor
 //--------Up Button If Statements-----------------------------------------------------------------------------------------------------------------------------------------------------------

  if (btn > 50 && btn <= 200 && x == 13)                                                  // If Up Button is Pressed and cursor is in the 1's of seconds position
  {
    delay(db);                                                                            // Button Debounce
    a = (a++);                                                                            // Increments variable "i" by 1.
    if (a > 9) a = 0;                                                                     // Always keeps variable "i" between 0 and 9
    lcd.setCursor (x, y);                                                                 // Keep current cursor position
    lcd.print(a);                                                                         // Print Value of 'i' Variable
  }

  if (btn > 50 && btn <= 200 && x == 12)                                                  // If Up Button is Pressed and cursor is in the 10's of seconds position
  {
    delay(db);                                                                            // Button Debounce
    b = (b++);                                                                            // Increments variable "i" by 1.
    if (b > 5) b = 0;                                                                     // Always keeps variable "i" between 0 and 9
    lcd.setCursor (x, y);                                                                 // Keep current cursor position
    lcd.print(b);                                                                         // Print Value of 'i' Variable
  }

  if (btn > 50 && btn <= 200 && x == 8)                                                   // If Up Button is Pressed and cursor is in the 1's of minutes position
  {
    delay(db);                                                                            // Button Debounce
    c = (c++);                                                                            // Increments variable "i" by 1.
    if (c > 9) c = 0;                                                                     // Always keeps variable "i" between 0 and 9
    lcd.setCursor (x, y);                                                                 // Keep current cursor position
    lcd.print(c);                                                                         // Print Value of 'i' Variable
  }

  if (btn > 50 && btn <= 200 && x == 7)                                                   // If Up Button is Pressed and cursor is in the 10's of minutes position
  {
    delay(db);                                                                            // Button Debounce
    d = (d++);                                                                            // Increments variable "i" by 1.
    if (d > 5) d = 0;                                                                     // Always keeps variable "i" between 0 and 9
    lcd.setCursor (x, y);                                                                 // Keep current cursor position
    lcd.print(d);                                                                         // Print Value of 'i' Variable
  }

  if (btn > 50 && btn <= 200 && x == 3)                                                   // If Up Button is Pressed and cursor is in the 1's of hours position
  {
    delay(db);                                                                            // Button Debounce
    e = (e++);                                                                            // Increments variable "i" by 1.
    if (e > 9) e = 0;                                                                     // Always keeps variable "i" between 0 and 9
    lcd.setCursor (x, y);                                                                 // Keep current cursor position
    lcd.print(e);                                                                         // Print Value of 'i' Variable
  }

  if (btn > 50 && btn <= 200 && x == 2)                                                   // If Up Button is Pressed and cursor is in the 10's of hours position
  {
    delay(db);                                                                            // Button Debounce
    f = (f++);                                                                            // Increments variable "i" by 1.
    if (f > 9) f = 0;                                                                     // Always keeps variable "i" between 0 and 9
    lcd.setCursor (x, y);                                                                 // Keep current cursor position
    lcd.print(f);                                                                         // Print Value of 'i' Variable
  }
  //--------Down Button If Statements-------------------------------------------------------------------------------------------------------------------------------------------------------------

  {
    if (btn > 200 && btn <= 400 && x == 13)                                             // If Down Button is Pressed and cursor is in the 1's of seconds, do this:
    {
      delay(db);                                                                        // Button Debounce
      a = a--;                                                                          // Decrements variable "i" by 1.
      if (a < 0) a = 9;                                                                 // Always keeps variable "i" between 0 and 9
      lcd.setCursor (x, y);                                                             // Keep current cursor position
      lcd.print(a);                                                                     // Print Value of 'i' Variable
    }

    if (btn > 200 && btn <= 400 && x == 12)                                             // If Down Button is Pressed and cursor is in the 10's of seconds, do this:
    {
      delay(db);                                                                        // Button Debounce
      b = b--;                                                                          // Decrements variable "i" by 1.
      if (b < 0) b = 5;                                                                 // Always keeps variable "i" between 0 and 9
      lcd.setCursor (x, y);                                                             // Keep current cursor position
      lcd.print(b);                                                                     // Print Value of 'i' Variable
    }

    if (btn > 200 && btn <= 400 && x == 8)                                              // If Down Button is Pressed and cursor is in the 1's of minutes, do this:
    {
      delay(db);                                                                        // Button Debounce
      c = c--;                                                                          // Decrements variable "i" by 1.
      if (c < 0) c = 9;                                                                 // Always keeps variable "i" between 0 and 9
      lcd.setCursor (x, y);                                                             // Keep current cursor position
      lcd.print(c);                                                                     // Print Value of 'i' Variable
    }

    if (btn > 200 && btn <= 400 && x == 7)                                              // If Down Button is Pressed and cursor is in the 10's of minutes, do this:
    {
      delay(db);                                                                        // Button Debounce
      d = d--;                                                                          // Decrements variable "i" by 1.
      if (d < 0) d = 5;                                                                 // Always keeps variable "i" between 0 and 9
      lcd.setCursor (x, y);                                                             // Keep current cursor position
      lcd.print(d);                                                                     // Print Value of 'i' Variable
    }

    if (btn > 200 && btn <= 400 && x == 3)                                              // If Down Button is Pressed and cursor is in the 10's of hours, do this:
    {
      delay(db);                                                                        // Button Debounce
      e = e--;                                                                          // Decrements variable "i" by 1.
      if (e < 0) e = 9;                                                                 // Always keeps variable "i" between 0 and 9
      lcd.setCursor (x, y);                                                             // Keep current cursor position
      lcd.print(e);                                                                     // Print Value of 'i' Variable

    }

    if (btn > 200 && btn <= 400 && x == 2)                                              // If Down Button is Pressed and cursor is in the 1's of hours, do this:
    {
      delay(db);                                                                        // Button Debounce
      f = f--;                                                                          // Decrements variable "i" by 1.
      if (f < 0) f = 9;                                                                 // Always keeps variable "i" between 0 and 9
      lcd.setCursor (x, y);                                                             // Keep current cursor position
      lcd.print(f);                                                                     // Print Value of 'i' Variable
    }
  }
  //------End Of Right, Left, Up, and Down keypad detection and cursor movement and number selection mode-----------------------------------------------------------------------------------------------------------------------------------
 //------SELECT MODE -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

  {
    if (btn > 600 && btn <= 800)                                // Start Countdown. Select Button Press. My Pin reading is 720. If Pin 0 reads between 601-800, do this:
    { delay(db);
      s = (s++);                                                //Increment s
    }
    if (s == 1)                                                 //If "s" equals 1, do this



      //------Start Timer Equations----------------------------------------------------------------------------------------------------------------------------------------------------
      if (a == 0 && b == 0 && c == 0 && d == 0 && e == 0 && f == 0)             //If Timer reaches 0, do this:
      {
        lcd.setCursor (0, 0);
        lcd.print ("** Times Up!! **");                                         //Print "Times Up!!"
        delay(500);
        lcd.setCursor (0, 0);
        lcd.print ("                ");                                         //Clear "Times Up!!"
        delay(500);
      }
      else                                             //else, if timer has not reached 0, do this:

      { if (a >= 0 )                                   //If  1's of seconds is >= 0                         00
        {
          a = (a--);                                   //Decrement 1's of seconds                           01 => 00
          if (a < 0)                                   //If 1's of seconds < 0                              -.01
          {
            a = 9;                                     //Rollback 1's of seconds to 9                       00 => 09
            b = (b--);                                 //Decrement 10's of seconds                          10 => 00

            if (b < 0)                                 //If 10's of seconds < 0                             -.01
            {
              b = 5;                                   //Rollback 10's of seconds to 5                      00 => 50
              c = (c--);                               //Decrement 1's of Minutes                           01 => 00

              if (c < 0)                               //If 1's of minutes < 0                              -.01
              {
                c = 9;                                 //Rollback 1's of minutes to 9                       10 => 19
                d = (d--);                             //Decrement 10's of minutes                          10 => 00
              }
              if (d < 0)                               //If 10's of minutes <0                              -.01
              {
                d = 5;                                 //Rollback 10's of minutes to 5                       01 => 51
                e = (e--);                             //Decrement 1's of hours                              01 => 00

                if (e < 0)                             //If 1's of hours < 0                                 -.01
                {
                  e = 9;                               //Rollback 1's of hours to 9                          10 => 19
                  f = (f--);                           //Decrement 10's of hours                             19 => 09

                  if (f < 0)                           //If 10's of hours < 0                                -.01
                  {
                    f = 0;                             // 10's of hours = 0 (max allowed is 10's of hours)   -.01 = 0
                  }
                }
              }
            }
          }
        }