How do I subtract a char digit value to create a LCD countdown?

I am, for those who have not read my recent posts, creating an airsoft "bomb" and I need the LCD to display the time countdown before detonation. From a keypad I enter the required disarm code and time before detonation. After help with some trouble I have had I have got that to work properly. When reading from the keypad I get values in a char array (Timer) and I can display it on my LCD, but I don't know how to manage the countdown. I have written the code as if I had the set time stored as int, just to get you an idea of what I want to do, and am hoping that someone could tell me how to.

void countdown()
{
  while (Timer[0] > 0 || Timer[1] > 0 || Timer[2] > 0 || Timer[3] > 0)
  {
    lcd.clear ();
    lcd.print("DETONATION IN:");
    lcd.setCursor(0, 2);
    lcd.print(Timer[0]);
    lcd.setCursor(1, 2);
    lcd.print(Timer[1]);
    lcd.setCursor(2, 2);
    lcd.print(":");
    lcd.setCursor(3, 2);
    lcd.print(Timer[2]);
    lcd.setCursor(4, 2);
    lcd.print(Timer[3]);
    delay(1000);
    if (Timer[1] >= 1 && Timer[2] == 0 && Timer[3] == 0 && Timer[4] == 0)
    {
      Timer[1] = Timer[1] - 1;
      Timer[2] = 9;
      Timer[3] = 5;
      Timer[4] = 9;
    }
    else if (Timer[2] >= 1 && Timer[3] == 0 && Timer[4] == 0)
    {
      Timer[2] = Timer[2] - 1;
      Timer[3] = 5;
      Timer[4] = 9;
    }
    else if (Timer[3] >= 1 && Timer[4] == 0)
    {
      Timer[3] = Timer[3] - 1;
      Timer[4] = 9;
    }
    else
    {
      Timer[4] = Timer[4] - 1;
    }
  }
}

The ASCII for the char 0 is 48.

When reading from the keypad I get values in a char array (Timer)

Terminate the array with a zero to make it a string then convert it to an int using the atoi() function.

Thanks guys! I'll try it out tonight. :slight_smile: