Pages: [1]   Go Down
Author Topic: how to get 4 digit decimal no.  (Read 521 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. 
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25884
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

(post your code if you want help)
Logged

"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.

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Rob Tillaart

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

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 212
Posts: 13531
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Rob Tillaart

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

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48566
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: