user73806: I found this code for a kitchen timer, it was the closest thing to a countdown. The code is here:

#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

signed short minutes, secondes;
char timeline[16];

void setup() {

  lcd.begin(16, 2);
  lcd.print("Chronometre :");


}

void loop() {

  lcd.setCursor(0, 1);
  sprintf(timeline,"%0.2d mins %0.2d secs", minutes, secondes);
  lcd.print(timeline);
  
  delay(1000);
  secondes++;
  
  if (secondes == 60)
  {
    secondes = 0;
    minutes ++;
  }

}


How do I convert it properly for it to countdown from 1 minute and 30 seconds?

user19409: As a start, you need to initalise the secondes and minutes variables to 30 and 1 respectively.
replace signed short minutes, secondes; with:
signed short minutes = 1;
signed short secondes = 30;

Next thing I notice is that the code you have provided counts up and you have requested that it count down.
Change secondes++; and minutes++; with:
secondes--;
minutes--;

Lastly you need to change the logic for when the secondes and minutes variables reach zero.
If the secondes variable reaches zero but the minutes variable is greater than zero, then you decrement the minutes (using the line of code provided above) and top-up the secondes with 59.
secondes = 59;

You will need to check the value of the secondes and minutes variables using a couple of if...else statements.
if (secondes == 0 && minutes == 0) {
    // insert your timer finished code here
}
else if ( secondes == 0 && minutes > 0) {
    minutes--;
    secondes = 59;
}
else {
    // Error - your code should not reach here.
    // Display an error message on the LCD
}

This if..else statement will need to go at the top of your loop instead of the end.

user37523: The first thing I recommend is that you don't use sprintf(). Your sketch "program storage space" drops from 3502 bytes down to 1928 bytes by NOT using that function call, and dynamic memory used drops from 101 to 79 bytes.
I would recommend an OOP design that would make it easy to add functionality, like the ability to start, stop and reset the timer.
// Arduino Uno, IDE version 1.8.9
// 2330 bytes (7%) of program storage space.
// Global variables use 201 bytes (9%) of dynamic memory.
class CountdownTimer{

  private:

    byte m_hour;
    byte m_minute;
    byte m_second;
    byte m_timerActive;
    byte m_timerComplete;
    unsigned long m_previousMillis;

  public:

    CountdownTimer():
      m_hour(0),
      m_minute(0),
      m_second(0),
      m_timerActive(0),
      m_timerComplete(0),
      m_previousMillis(0){}

    bool Update(){

      if(m_hour == 0 && m_minute == 0 && m_second == 0){
        m_timerComplete = 1;
        return 0;
      }

      if(m_timerActive && (millis() - m_previousMillis >= 1000)){
        m_previousMillis += 1000;
        m_second--;
        if(m_second == 255){
          m_second = 59;
          m_minute--;
          if(m_minute == 255){
            m_minute = 59;
            m_hour--;
            if(m_hour == 255){
              m_hour = 0;
            }
          }
        }
        return 1;
      }
      else{
        return 0;
      }
    }

    byte GetIsTimerComplete(){
      return m_timerComplete;
    }

    void SetHour(byte hour){
      m_hour = constrain(hour, 0, 23);
    }

    void SetMinute(byte minute){
      m_minute = constrain(minute, 0, 59);
    }

    void SetSecond(byte second){
      m_second = constrain(second, 0, 59);
    }

    void Start(){
      m_timerActive = 1;
    }

    void Stop(){
      m_timerActive = 0;
    }

    void ReStart(){
      m_timerActive = 1;
      m_timerComplete = 0;
      m_previousMillis = millis();
    }

    void PrintTimeRemaining(){
      if(m_hour < 10){Serial.print("0");}
      Serial.print(m_hour);
      Serial.print(":");
      if(m_minute < 10){Serial.print("0");}
      Serial.print(m_minute);
      Serial.print(":");
      if(m_second < 10){Serial.print("0");}
      Serial.println(m_second);
    }

};

// Make a copy of the object to work with.
CountdownTimer myCountdownTimer;
  
void setup(){

  // Built in pin 13 LED timer completed indicator.
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);

  // Test output to the serial monitor.
  Serial.begin(9600);

  // Set the countdown timer values,
  // start the countdown timer and
  // print the initial timer setting.
  myCountdownTimer.SetHour(0);
  myCountdownTimer.SetMinute(1);
  myCountdownTimer.SetSecond(30);
  myCountdownTimer.Start();
  myCountdownTimer.PrintTimeRemaining();
}

void loop(){

  // Call the Update function as fast as possible.
  if(myCountdownTimer.Update()){
    myCountdownTimer.PrintTimeRemaining();
  }

  // Turn on the Uno's Pin 13 LED once timer is complete.
  if(myCountdownTimer.GetIsTimerComplete()){
    digitalWrite(LED_BUILTIN, HIGH);
  }

}


73806: <p>I found this code for a kitchen timer, it was the closest thing to a countdown. The code is here:</p>
<pre><code>
#include &lt;LiquidCrystal.h&gt;

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

signed short minutes, secondes;
char timeline[16];

void setup() {

  lcd.begin(16, 2);
  lcd.print(&quot;Chronometre :&quot;);


}

void loop() {

  lcd.setCursor(0, 1);
  sprintf(timeline,&quot;%0.2d mins %0.2d secs&quot;, minutes, secondes);
  lcd.print(timeline);
  
  delay(1000);
  secondes++;
  
  if (secondes == 60)
  {
    secondes = 0;
    minutes ++;
  }

}

</code></pre>
<p>How do I convert it properly for it to countdown from 1 minute and 30 seconds?</p>
 19409: <p>As a start, you need to initalise the <code>secondes</code> and <code>minutes</code> variables to 30 and 1 respectively.</p>
<p>replace <code>signed short minutes, secondes;</code> with:</p>
<pre><code>signed short minutes = 1;
signed short secondes = 30;
</code></pre>
<p>Next thing I notice is that the code you have provided counts up and you have requested that it count down.</p>
<p>Change <code>secondes++;</code> and <code>minutes++;</code> with:</p>
<pre><code>secondes--;
minutes--;
</code></pre>
<p>Lastly you need to change the logic for when the <code>secondes</code> and <code>minutes</code> variables reach zero.</p>
<p>If the <code>secondes</code> variable reaches zero but the <code>minutes</code> variable is greater than zero, then you decrement the minutes (using the line of code provided above) and top-up the <code>secondes</code> with 59.</p>
<pre><code>secondes = 59;
</code></pre>
<p>You will need to check the value of the <code>secondes</code> and <code>minutes</code> variables using a couple of <a href="https://www.arduino.cc/reference/en/language/structure/control-structure/if/" rel="nofollow noreferrer">if</a>...<a href="https://www.arduino.cc/reference/en/language/structure/control-structure/else/" rel="nofollow noreferrer">else</a> statements.</p>
<pre><code>if (secondes == 0 &amp;&amp; minutes == 0) {
    // insert your timer finished code here
}
else if ( secondes == 0 &amp;&amp; minutes &gt; 0) {
    minutes--;
    secondes = 59;
}
else {
    // Error - your code should not reach here.
    // Display an error message on the LCD
}
</code></pre>
<p>This if..else statement will need to go at the top of your loop instead of the end.</p>
 37523: <p>The first thing I recommend is that you don't use sprintf(). Your sketch &quot;program storage space&quot; drops from 3502 bytes down to 1928 bytes by NOT using that function call, and dynamic memory used drops from 101 to 79 bytes.</p>
<p>I would recommend an OOP design that would make it easy to add functionality, like the ability to start, stop and reset the timer.</p>
<pre><code>// Arduino Uno, IDE version 1.8.9
// 2330 bytes (7%) of program storage space.
// Global variables use 201 bytes (9%) of dynamic memory.
class CountdownTimer{

  private:

    byte m_hour;
    byte m_minute;
    byte m_second;
    byte m_timerActive;
    byte m_timerComplete;
    unsigned long m_previousMillis;

  public:

    CountdownTimer():
      m_hour(0),
      m_minute(0),
      m_second(0),
      m_timerActive(0),
      m_timerComplete(0),
      m_previousMillis(0){}

    bool Update(){

      if(m_hour == 0 &amp;&amp; m_minute == 0 &amp;&amp; m_second == 0){
        m_timerComplete = 1;
        return 0;
      }

      if(m_timerActive &amp;&amp; (millis() - m_previousMillis &gt;= 1000)){
        m_previousMillis += 1000;
        m_second--;
        if(m_second == 255){
          m_second = 59;
          m_minute--;
          if(m_minute == 255){
            m_minute = 59;
            m_hour--;
            if(m_hour == 255){
              m_hour = 0;
            }
          }
        }
        return 1;
      }
      else{
        return 0;
      }
    }

    byte GetIsTimerComplete(){
      return m_timerComplete;
    }

    void SetHour(byte hour){
      m_hour = constrain(hour, 0, 23);
    }

    void SetMinute(byte minute){
      m_minute = constrain(minute, 0, 59);
    }

    void SetSecond(byte second){
      m_second = constrain(second, 0, 59);
    }

    void Start(){
      m_timerActive = 1;
    }

    void Stop(){
      m_timerActive = 0;
    }

    void ReStart(){
      m_timerActive = 1;
      m_timerComplete = 0;
      m_previousMillis = millis();
    }

    void PrintTimeRemaining(){
      if(m_hour &lt; 10){Serial.print(&quot;0&quot;);}
      Serial.print(m_hour);
      Serial.print(&quot;:&quot;);
      if(m_minute &lt; 10){Serial.print(&quot;0&quot;);}
      Serial.print(m_minute);
      Serial.print(&quot;:&quot;);
      if(m_second &lt; 10){Serial.print(&quot;0&quot;);}
      Serial.println(m_second);
    }

};

// Make a copy of the object to work with.
CountdownTimer myCountdownTimer;
  
void setup(){

  // Built in pin 13 LED timer completed indicator.
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, LOW);

  // Test output to the serial monitor.
  Serial.begin(9600);

  // Set the countdown timer values,
  // start the countdown timer and
  // print the initial timer setting.
  myCountdownTimer.SetHour(0);
  myCountdownTimer.SetMinute(1);
  myCountdownTimer.SetSecond(30);
  myCountdownTimer.Start();
  myCountdownTimer.PrintTimeRemaining();
}

void loop(){

  // Call the Update function as fast as possible.
  if(myCountdownTimer.Update()){
    myCountdownTimer.PrintTimeRemaining();
  }

  // Turn on the Uno's Pin 13 LED once timer is complete.
  if(myCountdownTimer.GetIsTimerComplete()){
    digitalWrite(LED_BUILTIN, HIGH);
  }

}
</code></pre>
