Convert to Decimal


Closed Thread
Results 1 to 8 of 8
  1. #1
    mglazer's Avatar
    mglazer Guest

    Default Convert to Decimal

    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

  2. #2
    J_Brittian's Avatar
    J_Brittian Guest


    Did you find this post helpful? Yes | No

    Default

    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]

  3. #3
    mglazer's Avatar
    mglazer Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks for the reply, Yeh ive tried using dec and the compiler just gives bad expression errors.

  4. #4
    mytekcontrols's Avatar
    mytekcontrols Guest


    Did you find this post helpful? Yes | No

    Default

    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.

  5. #5
    mglazer's Avatar
    mglazer Guest


    Did you find this post helpful? Yes | No

    Thumbs up

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

  6. #6
    mytekcontrols's Avatar
    mytekcontrols Guest


    Did you find this post helpful? Yes | No

    Thumbs up Cool!

    Opps, almost missed your response!

    Well I'm glad that worked out for you mglazer

  7. #7


    Did you find this post helpful? Yes | No

    Smile Code

    Hello,

    Can you publish your code to see it?.



    Quote Originally Posted by mglazer
    It works very well, thank you for that code. Much Appreciated.

  8. #8


    Did you find this post helpful? Yes | No

    Smile Code

    Hello,

    Can you publish your code to see it?.

    Quote Originally Posted by mglazer
    It works very well, thank you for that code. Much Appreciated.

Similar Threads

  1. Convert long binary number to ASCII Decimal
    By Joe Rocci in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 9th July 2009, 13:58
  2. How to convert binary to decimal?
    By Cabomba in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th October 2007, 01:27
  3. Convert Hex to Decimal
    By RONKON in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 9th May 2006, 01:01
  4. HOWTO Convert character to Decimal
    By NL2TTL in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th April 2005, 17:00
  5. Convert a word variable to decimal
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th December 2004, 20:02

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts