itoa() for 8 bits value ?

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I would like to check the voltage level of a 1.5 Volt battery with the ADC function of a Atmega16 ,and send it via the UART to a pc.

I have enough with 8 bits, and will not use the 2 least
significant bits. ( 10 bits ADC )
I have set the ADLAR bit:
"Consequently,
if the result is left adjusted and no more than 8-bit precision is required, it is sufficient to read ADCH."

iota() looks a usefull function but this for an
integer.

What can I do If I would like to convert only 8 bits to asci ?

Thanks,

Last Edited: Mon. Aug 20, 2007 - 10:01 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Give your 8-bit value as a parameter to itoa(). The value will be promoted to an int.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oo, I was not aware of this, just test it in Studio watched the buffer containing the Asci characters looks good.

Thanks,

Last Edited: Mon. Aug 20, 2007 - 10:42 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can scale results of measure by multiply it by 8 or 16 bit integer and shift right then convert to string as integer and insert dot (if this is really needed) in this string.