Lcd display time in x.x secounds

hello guys

how can i display a time in .1 secounds ?
i know how to display seconds (mills/1000)
but how do i get that 0. seconds ?

Try

millis()/1000.0
2 Likes

okay i will give that a try :+1:

if i dont find a fix i will draw a dot with a pen on the display :sweat_smile:

you can print it with xxx.print('.'); where xxx is either Serial or lcd.

i need to print unsigned ling RelayMillisDelay = 3000;
now i print it like this:
lcd.print (RelayMillisDelay / 1000);
then the value is 3s on the display but i need 3.0
and if the value is 3100 mills it should be 3.1 s

lcd.print (RelayMillisDelay / 1000.0, 1);

Hello @domsn123 - When I want to have the decimal points align, I use zeroes ("0") or spaces (" ") on the front of numbers (and with decimal values), I make functions called "zeroPad()" or "spacePad()"... it looks like this...

int val1 = 255;
int val2 = 42;
float val3 = 0.15;

void setup() {
  Serial.begin(9600);

  Serial.print("ZeroPad");
  Serial.print("\t\t");
  Serial.println("SpacePad");

  zeroPad(val1);
  Serial.print("\t\t");
  spacePad(val1);

  zeroPad(val2);
  Serial.print("\t\t");
  spacePad(val2);

  zeroPad(val3);
  Serial.print("\t\t");
  spacePad(val3);
}

void loop() {}

void zeroPad(float num) {
  if (num < 1000) Serial.print("0");
  if (num < 100) Serial.print("0");
  if (num < 10) Serial.print("0");
  Serial.print(num);
}

void spacePad(float num) {
  if (num < 1000) Serial.print(" ");
  if (num < 100) Serial.print(" ");
  if (num < 10) Serial.print(" ");
  Serial.println(num);
}

The results:

ZeroPad		SpacePad
0255.00		 255.00
0042.00		  42.00
0000.15		   0.15

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.