byte/ int/ uint8_t/ Serial.print [SOLVED]

Okay... Dumb??

I was working with someone else's cod, and I THINK the data type of the "thing" I was working with was uint8_t.

The thing I was working with was "rtc.sec"

I think it returns 0, 1, 2.... 59 from a real time clock, depending on when you access it. (Assuming you've done "ds1302.gettime(&rtc)" shortly before accessing rtc.sec

ANYWAY...

When I created a byte type variable, and did...

bTmp=rtc.sec; Serial.print(bTmp);

... part of the sequence I got was...

... 23456789;:...

Always one character per call of Serial.print(bTmp)

When I created an INTEGER type variable, iTmp, and did....

iTmp=rtc.sec; Serial.print(iTmp);

... I got what I would have expected to get before....

...22232425262728293031....

... the numbers 0 to 59, and then 0 to 59 again and again.

HELP??!!

What am I missing about... whatever I'm missing something about?!

(I would post the whole code for you, but the critical bits for full analysis are buried in #included files, which themselves #include files, etc, etc!)

== PS: Thank you, westfw for the reply you posted... made everything clear to me, and even showed me how to "fix" what was giving me trouble!

What am I missing

Serial.print is an "overloaded" function, which means it executes different code depending on the type and quantity of the arguments. All it with an int, and it prints it as a decimal number. Call it with a float, and it prints floating point. Call it with a "char" or similar, and it prints a raw character. These are "best guesses" at the desired format.

You can force the format with a second argument:

Serial.print(mybyte, DEC);
Serial.print(myint, BYTE);

It is mentioned in the documentation: http://arduino.cc/en/Serial/Print

Also, calling Serial.print("Some meaningful prefix: "); before Serial.println(someVariable); is generally very useful.