Shop OBEX P1 Docs P2 Docs Learn Events
BS2 PBasic Variable Question - Serial LCD Backpack #117 — Parallax Forums

BS2 PBasic Variable Question - Serial LCD Backpack #117

Just JeffJust Jeff Posts: 36
edited 2012-02-26 21:50 in BASIC Stamp
Hello,

I have a PBasic / code question relating to a Peter Anderson #117 LCD serial backpack connected to a BS2 and maybe somebody on here has some experience with this issue.

Trying to pass the contents / results of a variable in PBasic on a BS2 to the LCD and am confused;

Code snippets...

This works!...
SEROUT LCDPin, 84, ["?y2?x11Stop"] 'Works and displays the desired "Stop"

This doesn't....
Var1 VAR WORD
Var1 = Stop
SEROUT LCDPin, 84, ["?y3?x00Var1"] 'Does not work, how can I do this?

Thank you for any assistance!!!

note.... The "?y2?x11.. are commands that clear the display, position the cursor in x & y location etc. and they all work perfectly

Comments

  • Martin_HMartin_H Posts: 4,051
    edited 2012-02-25 13:51
    I have that lcd backpack and use it frequently. Your first line should position the cursor at the location and prints a literal string. The second positions it a line below with x at the left, and also prints a literal string, not your variable.

    Try this:

    SEROUT LCDPin, 84, ["?y3?x00"], DEC Var1 ' this should print your variable as decimal. A word is too small for a string.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2012-02-25 13:55
    Jeff,
    Basic Stamps don't have string variables per se, so if you want to print a "text" variable you need to define an array and loop thru it printing one byte at time.

    e.g. myList VAR Byte(10) ' Create a 10-byte array. (see pages 87-88 of the manual)


    A WORD only holds two bytes so even if this were legal, it wouldn't hold four characters:

    Var1 VAR WORD
    Var1 = Stop

    If you want to print a constant, define it using DATA - remember you only have 26 bytes of variable space.


  • Just JeffJust Jeff Posts: 36
    edited 2012-02-25 17:35
    Ahhh, OK Thanks guys!!
  • Just JeffJust Jeff Posts: 36
    edited 2012-02-26 03:00
    Martin_H wrote: »
    I have that lcd backpack and use it frequently. Your first line should position the cursor at the location and prints a literal string. The second positions it a line below with x at the left, and also prints a literal string, not your variable.

    Try this:

    SEROUT LCDPin, 84, ["?y3?x00"], DEC Var1 ' this should print your variable as decimal. A word is too small for a string.

    Martin_H do you by chance have any examples of menus that you have worked out that you wouldn't mind sharing?... Needing some inspiration!
  • Martin_HMartin_H Posts: 4,051
    edited 2012-02-26 03:54
    I use it strictly to display status of my robot, but I can post the code later.
  • Just JeffJust Jeff Posts: 36
    edited 2012-02-26 09:56
    Thanks Martin_H that will really help to have an example to look over!!
  • Martin_HMartin_H Posts: 4,051
    edited 2012-02-26 18:15
    Jeff,

    The program CBA Say It Demo.BSE uses the SayIt module to obtain voice commands which are then displayed in the LCD. So it is a voice menu system which might be close enough to be helpful to you. This is a multi bank program for the BS2E and the second program is my compass module program. You can pretty much ignore that, but I included it so you can see the whole program.

    CBA Say It Demo.bse

    Hm55bCompass.BSE

    Hope you find this helpful.

    Martin
  • Just JeffJust Jeff Posts: 36
    edited 2012-02-26 21:50
    Martin_H wrote: »
    ........ it so you can see the whole program.

    Hope you find this helpful.

    Martin

    Thanks!!!!!!
Sign In or Register to comment.