Quote Originally Posted by jmgelba View Post
I have a little project where I need to read 0 - 30Vdc. I've used a 100K /10K divider to give a max of 3V into the ADC pin.
My Vref is 5.000V and I'm using a 10bit ADC.

5/1024 = 0.0048V per count

3V = 625
625x48 = 30000

How do I get a count of 625 to display as 30.00V?

Code:
ADCIN 1, LEDCOUNT
LEDVOLT = LEDCOUNT * 48 
LEDV0 = LEDVOLT/10
LEDV1 = LEDVOLT//10         
 
PAUSE 200
 
LCDOUT $FE,1, "LED VOLTS ", DEC2 LEDV0, ".", DEC1 LEDV1, "V"
This gives me a display of xx.xV not xx.xxV

If you want two decimal places (xx.xxV):

Number_you_want_to_display = (LEDCNT * 48)/10


"LED VOLTS",DEC2 (Number_you_want_to_display/100),".",DEC2 (Number_you_want_to_display //100)

;-----------------------------------------------------------------------------
If you want 3 decimal places: (xx.xxxV):

Number_you_want_to_display = LEDCNT*48

"LED VOLTS",DEC2 (Number_you_want_to_display/1000),".",DEC3 (Number_you_want_to_display //1000)