Continue to Site

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.

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

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
 
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..
 
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
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top