SOTASOTA
- 14th December 2010, 20:35
I have a newbie question. I wish to display a value on an LCD 16*2 display.
Got the display working great.
I read the values on PortB and wish to convrt what I read into a percentage of full scale.
I total all the values on PortB and store into variable WTotal (WTotal var WORD). I also have declared variable WTotalPercentage (WTotalPercentage var WORD).
The values go from 0 to 1275.
I wish to show a percentage based on a full scale reading of 1275.
For example:
If I read a vaule of 256, this represents approx. 20% of 1275.
The math being WTotalPercentage = WTotal/1275*100
Simple.
Now how do I display the value of WTotalPercentage in an LCD display?
If I use:
LCDOUT DEC (WTotalPercentage)
I get a reading of zero. I think it lies in the math of WTotalPercentage = WTotal/1275*100, however I do not know how picBasic math function work.
Help!
Got the display working great.
I read the values on PortB and wish to convrt what I read into a percentage of full scale.
I total all the values on PortB and store into variable WTotal (WTotal var WORD). I also have declared variable WTotalPercentage (WTotalPercentage var WORD).
The values go from 0 to 1275.
I wish to show a percentage based on a full scale reading of 1275.
For example:
If I read a vaule of 256, this represents approx. 20% of 1275.
The math being WTotalPercentage = WTotal/1275*100
Simple.
Now how do I display the value of WTotalPercentage in an LCD display?
If I use:
LCDOUT DEC (WTotalPercentage)
I get a reading of zero. I think it lies in the math of WTotalPercentage = WTotal/1275*100, however I do not know how picBasic math function work.
Help!