Need help with SINGLE variable..

Status
Not open for further replies.

mastero

Member
Hello

I am making a simple pressure sensor all works fine.
i get the output reading as XX.XXX on a 16x2 LCD

i want only the XX before the decimal to be displayed. Help please.


Code:
Dim Pressure as Single

displaypressure:
		Adcin 0, analogread
		pressure = analogread * 5.0 / 1024
		pressure = (pressure - 0.54) / 0.059
		Lcdcmdout LcdLine1Clear
		Lcdcmdout LcdLine1Home
		Lcdout "PRESSURE", ":", " ", " ", #pressure
Return

cheers
Mastero
 
...deleted...
 
Last edited:
I would try to cast... example..

Code:
Dim Pressure as Single
Dim DispPressure as word

displaypressure:
        Adcin 0, analogread
        pressure = analogread * 5.0 / 1024
        pressure = (Pressure - 0.54) / 0.059
        DispPressure = Pressure
        Lcdcmdout LcdLine1Clear
        Lcdcmdout LcdLine1Home
        Lcdout "PRESSURE", ":", " ", " ", #DispPressure
Return

That should get rid of the floating points..Untested ..Try it.
 
the pressure you are getting is an analog thing you want to convert it to a digital thing
try this:
  • int r(float f) {
  • int result = f;
  • return result; // You could just write "return f;" instead.
  • }
~~Cris
 
the pressure you are getting is an analog thing you want to convert it to a digital thing
try this:
  • int r(float f) {
  • int result = f;
  • return result; // You could just write "return f;" instead.
  • }
~~Cris
That is C This is Oshonsoft Basic forum.. Singes are new to the platform..
 


PERFECT Thanks
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…