60 sec count down

Can someone help me how can I print the numbers on 16x2 lcd with out the decimal point. Im doing a countdown on my program thanks. :slight_smile:

#include <LiquidCrystal.h>

//LiquidCrystal lcd(RS, E, D4, D5, D6, D7);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);      // put your pin numbers here


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

// set cursor position to start of first line on the LCD
lcd.setCursor(0,0);
//text to print

delay(100);


float b=15; 
  

while(b!=1)
{
  b=b-1;
  delay(1000);
  lcd.setCursor(0,1);
  lcd.print("        ");
  lcd.print(b); 
  lcd.setCursor(0,0);

}

}
void loop()
{

}

 float b = 15;

Why is b declared as a float ? By default floats are printed with 2 decimal places

Change it to a byte

If I changed it to bytes or int. When it reaches 9 the 9 becomes 90 the 8 becomes 80 the 7 becomes 70

so it will print as.

15
14
13
12
11
10
90
80
70
60
50
40
30
20
10

Clear the display before going from 10 to 9

When it reaches 9 the 9 becomes 90 the 8 becomes 80 the 7 becomes 70

You are not erasing the zero left by printing the 10

Options : always follow the printing of the number with a space or better, only do it if the number is less than 10. Actually, only doing it when the number is 9 would work, or always print spaces where you will be printing the number. The sledgehammer (and worst) way to do it is to clear the LCD completely before printing the number

UKHeliBob:
You are not erasing the zero left by printing the 10

Options : always follow the printing of the number with a space or better, only do it if the number is less than 10. Actually, only doing it when the number is 9 would work, or always print spaces where you will be printing the number. The sledgehammer (and worst) way to do it is to clear the LCD completely before printing the number

Thanks so much UKHeliBob that was great suggestion :slight_smile: :slight_smile: :slight_smile:

that was great suggestion

Which one of the several suggestions did you use ?

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);      // put your pin numbers here

int16_t timerValue = 60;
uint32_t lastTime;

void updateLcd()
{
    lcd.setCursor(0,1);
    lcd.print("        ");
    lcd.print(timerValue);
    lcd.print(" ");
  
}

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

void loop() {
  uint32_t now = millis();
  if (now - lastTime > 1000) {
    lastTime += 1000;
    if (timerValue > 0)
    {
      timerValue--;
      updateLcd();
    }
  }
}