Go Down

Topic: how to get 4 digit decimal no. (Read 619 times) previous topic - next topic

maibam

i interface with analog voltage at pin no A0 and get the data. than i convert the data in to voltage but it has been showing upto 2 digit no not upto 4 digit no. but i need upto four 4 digit no so how can i get the value up to 4 digit no any suggestion. 

AWOL

Code: [Select]
Serial.print (myFloatVoltage, 4);
But, with 4mV resolution, this may not be what you want.

(post your code if you want help)
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

robtillaart

do you mean preceding zero's?  e.g. 0024 mV?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

With a print function you can define how many 0's you want after the decimal point
ie print(a0,2); will print to 2 decimal places.
I use this for voltages myself but I have found sometimes if the voltage is under ten and using an LCD 2 line display I will get 3 decimal places instead of 2.
Not sure if this problem occurs on serial monitor.
Hope this helps

robtillaart

Quote
I use this for voltages myself but I have found sometimes if the voltage is under ten and using an LCD 2 line display I will get 3 decimal places instead of 2.


Can you make a test application that shows this behaviour?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

PaulS

Quote
Can you make a test application that shows this behaviour?

I'd guess that it only happens when the value drops from over 10 to under 10, and OP isn't clearing the LCD display.

Go Up