0

I am trying to get a string containing the uptime of my Arduino. I'm using this code:

long t = millis() / 1000;
word h = t / 3600;
byte m = (t / 60) % 60;
byte s = t % 60;
String uptime =  h/10 + h%10 + m/10 + m%10 + s/10 + s%10;

But I get 'invalid conversion' errors. Should I do this with sprintf or something?

2 Answers 2

0

If you are forced to use C: yes, sprintf or, much better, snprintf is the right way to go for you. If you are using C++ and the STL is available, you should use std::string (but I am not sure if this is there).

Sign up to request clarification or add additional context in comments.

Comments

0

Its type cast operation needed . How you could expect work. one is integer , byte and reading in string format.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.