• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Need help with SINGLE variable..

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
 

jjw

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:

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
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.
 

phoenixcomm

New Member
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
 

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
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..
 

mastero

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

PERFECT :) Thanks
 

Latest threads

EE World Online Articles

Loading
Top