v = (read_u16() /65535) * 3.3 should work.
An integer read (read_u16) is usefull where you need to process the data quickly. Integer operations are (much) faster than floating point operations. An integer operation takes 1 or 2 cycles, whereas floating point operations can take up to 50-100 cycles. The precesion remains the same (i.e. you can't get more information using the integer read).
If you require fast performace, you should do all calculations with ints and convert to a float at the very end (if needed). This limits the number of (expensive) floating point operations.
Most of the time however, it's ok to indulge in floating point operations without concequence.
Hi guys, i'm trying to get a voltage value from an analog gyroscope that works at 3.3 V. The reading when there's no movement should be 1,65 V and my multimeter can confirm this, also if i use the analogin "read" i get values around 0.5 and that's ok.
However i need the actual voltage value so i tried the method read_u16 but when i printf to serial i get values around 33288 if i cast to int,otherwise i get 18 ..48 ..248 18 and so on.... what's this?
I just need advice on how to make calculations with the voltage value obtained and how to print it to screen! it's a simple u char but i can't get out of it :D
Thanks a lot