PDA

View Full Version : Convert to Decimal



mglazer
- 30th October 2005, 03:48
Hi,

How do I convert data to a decimal when using I2CWRITE e.g

I2CWRITE PortA.0, PortA.1, LCD, 0, [12, "Light: ", S1AmbientLight,13, "Range: ", S1Echo]

It displays perfect on the LCD except the two variables(S1AmbientLight & S1Echo) are jiberish.

Thanks for your help

J_Brittian
- 31st October 2005, 19:39
Try prefacing your variables with "dec". This may not work, I've never used I2CWRITE before. There is a table with various data prefaces under serout, hserout, and lcdout commands in the PicBasic manual. I'm not sure why the same table wouldn't be under the I2CWRITE command unless it was not applicable.

I2CWRITE PortA.0, PortA.1, LCD, 0, [12, "Light: ", dec S1AmbientLight,13, "Range: ", dec S1Echo]

mglazer
- 1st November 2005, 03:18
Thanks for the reply, Yeh ive tried using dec and the compiler just gives bad expression errors.

mytekcontrols
- 1st November 2005, 04:02
When you say convert to decimal are you talking about converting a byte into a 3 digit, or a word into a 5 digit formatted decimalized display (10,000's, 1,000's, 100's, 10's, 1's)? If so here's a link Click Me to something that might get you started, although it was originally intended to output over RS232. It would be a simple matter to convert it to your purposes.

mglazer
- 2nd November 2005, 03:20
It works very well, thank you for that code. Much Appreciated.

mytekcontrols
- 5th November 2005, 07:53
Opps, almost missed your response!

Well I'm glad that worked out for you mglazer :)

Leonardo
- 5th November 2005, 11:30
Hello,

Can you publish your code to see it?.




It works very well, thank you for that code. Much Appreciated.

Leonardo
- 5th November 2005, 11:31
Hello,

Can you publish your code to see it?.


It works very well, thank you for that code. Much Appreciated.