Shop OBEX P1 Docs P2 Docs Learn Events
BS2pe-How to make the LCD display a variable? — Parallax Forums

BS2pe-How to make the LCD display a variable?

nowhatevenowhateve Posts: 8
edited 2008-11-27 21:53 in BASIC Stamp
I am really new to the basic stamp.
According to the Reference Manual, it seems that the LCD only displays fixed values, such as LCDOUT [noparse][[/noparse]"Hello World!"]
Is it possible for the LCD to show a variable. Like LCDOUT[noparse][[/noparse]B1] (B1 is a variable. B1=B1-1 after each loop...)
I dont know how to achieve that.

Thank you for your help!!!

Comments

  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-27 21:25
    Sure. Where you might put "Hello World!", put the name of your variable instead. That variable must, of course, contain somethibg displayable, else the screen will look strange. In either case, you're simply telling the Stamp what bytes to send to the LCD. Whether those bytes are a fixed string like "Happy Thanksgiving" or are variables, the LCD won't know or care. All it knows is that some bytes came through the wire for it to display, and, by golly, it'll do its best.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i@arrl.net
  • nowhatevenowhateve Posts: 8
    edited 2008-11-27 21:45
    Thanks Carl. I tried putting the name of the variable in the place of "Hello World!"
    Here is what I did and what I got.

    B1 VAR WORD
    Lcd PIN 1
    LcdCls CON $01

    INITIALIZATION of LCD....

    Main:
    Do
    B1=60
    LCDOUT Lcd, LcdCls, [noparse][[/noparse]B1]
    PAUSE 1000
    B1=B1-1
    Loop
    END


    What I got on the LCD is a weird mark like ">"

    If try LCDOUT Lcd, LcdCls, [noparse][[/noparse]"60"]

    The LCD displays well.

    I was wondering if I could put a variable directly into the brackets[noparse]/noparse. Or there is some particular syntax for LCDOUT to display a variable?

    Thanks!
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-11-27 21:52
    Change LCDOUT Lcd, LcdCls, [noparse][[/noparse]B1] to LCDOUT Lcd, LcdCls, [noparse][[/noparse]DEC B1]
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-27 21:53
    When you put just the variable name, the Stamp outputs the contents of the variable as a character. If you want the value to display as something readable, you have to use one of the "formatters". They're described in detail as part of the SEROUT statement chapter, but work with the LCDOUT statement as well. You probably want "LCDOUT Lcd, LcdCls, [noparse][[/noparse]DEC B1]".
Sign In or Register to comment.