LCD display - Problem with display Countdown

Hello everyone.

I made a simple code in arduino to display a countdown on the LCD display.
I did the program, the LCD displays the countdown to the 10 normal below it is that it is strange why the numbers “go right”, and the count is so in the display:

13 12 11 10 90 08 70 60 50 40 30 20 10 00.

When should look like this:

13 12 11 10 09 08 07 06 05 04 03 02 01 00.

This is the code I did:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int cont = 015;

void setup()
{
lcd.begin(16, 2);
}
void loop()
{
if(cont <= 0)
{
cont = 015;
}
else
{
cont–;

}
delay(500);
lcd.setCursor(1, 0);
lcd.print(“CONT. REGRESSIVA”);
lcd.setCursor(1, 1);
lcd.print("TEMPO: " );
lcd.print(cont);
}

Did you really want octal e.g. 015 is 13 in decimal.

It is always wise ™ to print a space after a number. Then it erases the previous 0 left from 10.

Personally I would right-align the number. e.g. if (n < 10) print a space.

David.

Friend, I am new to the Arduino, we calmly:

1 In counting, using this variable that I put there, this unit is being told that this number system?

2 For me to get that this normal number, what should I do? If a score to stay in the units 09 or 009?

3 # To get for example, what command should I use to solve this?

If I put the display to clean the screen every loop, the count is normal otherwise is this problem. But stay with blinking screen is not a decent solution

A decimal number is 123
An octal number is 0123
A hexadecimal number is 0x123

Try this:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int cont = 13;    //use decimal number

void setup()
{
    lcd.begin(16, 2);
}

void loop()
{
    if (cont <= 0)
    {
        cont = 13;
    }
    else
    {
        cont--;

    }
    delay(500);
    lcd.setCursor(1, 0);
    lcd.print("CONT. REGRESSIVA");
    lcd.setCursor(1, 1);
    lcd.print("TEMPO: " );
    if (cont < 10) {       //right-align for small numbers
        lcd.print("0");   // pad with a zero
    }
    lcd.print(cont);
}

Note that I pressed [ctrl-T] key. This indented your code nicely.

Good Luck.

David.