Shop OBEX P1 Docs P2 Docs Learn Events
Sending a varible to a serial LCD — Parallax Forums

Sending a varible to a serial LCD

jjmonnsjjmonns Posts: 2
edited 2006-08-29 01:57 in General Discussion
I have been having trouble sending a varible to the parallax serial LCD.· I am using the SX48 proto board with the internal 4mhz.· I am able to send a string but I can't send a number variable correctly.· It comes out as random characters such as a series of backslashes.· Any help?

Comments

  • BeanBean Posts: 8,129
    edited 2006-08-27 18:48
    jjmonns,
    · You need to convert the variable into ASCII characters.
    · Here is a routine to convert a Word variable into 5 ASCII digits.

    Word_To_Digits  SUB 2
     
     
    Word_To_Digits:
      tempW = __WPARAM12
      char = "0" 
    
      DO WHILE tempW >= 10000
        INC char
        tempW = tempW - 10000
      LOOP
      SendChar char
     
      char = "0"
      DO WHILE tempW >= 1000
        INC char
        tempW = tempW - 1000
      LOOP
      SendChar char
     
      char = "0"
      DO WHILE tempW >= 100
        INC char
        tempW = tempW - 100
      LOOP
      SendChar char
     
      char = "0"
      DO WHILE tempW >= 10
        INC char
        tempW = tempW - 10
      LOOP
      SendChar char
     
      char = "0" + tempW_LSB
      SendChar char
     
      RETURN
    



    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com

    "You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh


    Post Edited (Bean (Hitt Consulting)) : 8/27/2006 6:52:45 PM GMT
  • jjmonnsjjmonns Posts: 2
    edited 2006-08-29 01:57
    Thanks for the help! I don't know how to make a variable a word with the SX. I was able to make it work with a byte and shortened it to work with that. Here is what I made:

    byte_To_Digits:
    tempW = __PARAM1
    char = "0"
    DO WHILE tempW >= 100
    INC char
    tempW = tempW - 100
    LOOP
    LCD_OUT char

    char = "0"
    DO WHILE tempW >= 10
    INC char
    tempW = tempW - 10
    LOOP
    LCD_OUT char

    char = "0" + tempW
    LCD_OUT char

    RETURN
Sign In or Register to comment.