Shop OBEX P1 Docs P2 Docs Learn Events
Help using a Parallax 2X16 LCD serial display. (#27976) — Parallax Forums

Help using a Parallax 2X16 LCD serial display. (#27976)

ihmechihmech Posts: 179
edited 2009-09-14 22:55 in BASIC Stamp
I have been playing around with a 2X16 LCD serial display.· I have no problem sending text and data to the display.· The problem I'm having is trying to figure out how to enter text with a push button interface and then be able to save the text in the stamps memory.· I want to be able to enter "dog" for example and save it.· Using two push buttons as an up/down setup to manually scroll·A through·Z.· I also want to have·"back" and "enter" buttons to confirm a letter selection or back up the cursor and fix an error.· After the text is entered, I want to save it to memory.· I hope someone can help me.

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-09-12 02:21
    Start by setting up your buttons and using debug to get the programming the way you want it then add the display code. Try writing small pieces of code to, say, scroll the letters A to Z then add the part that accepts a letter and so on.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • SRLMSRLM Posts: 5,045
    edited 2009-09-12 02:27
    Basically, you'll need to have a counter (byte size will work) that goes from decimal 65 to decimal 90 (A through Z, ASCII) and that you display on the screen. To make it seem like it's "scrolling", you'll need to move the cursor back and clear the letter, then display a new letter. Since you'll be building a word (literary word, not CS word (the size)), you'll need an array of some type to store the letters in. You could "store" them into the LCD by simply moving the cursor on to the next spot when the enter button is pushed, but that's your call. So, you'll probably want three "counter" type variables: a counter for the current letter (A to Z), a counter for the position in the array, and possibly a counter for where you want to store the word.
  • ihmechihmech Posts: 179
    edited 2009-09-12 10:31
    Thank you both very much for the help, I sat down and tried to come up with something and still had no luck. I'm still pretty new on stamps, I've been teaching myself and I don't have much experience with counters. If anyone could give some small examples, it would be greatly appreciated. Thanks
  • SRLMSRLM Posts: 5,045
    edited 2009-09-13 07:36
    The code below should get you started. I don't have the hardware with me to test it, but it should print out the A to Z on the LCD. The next step would be to modify it to print out the letters at the same spot on screen. To do that you'll need to figure out the appropriate commands from the LCD datasheet. They should be within the first forty or so commands. You'll also need to add a pause in there to slow things down so you can actually confirm that the letters are appearing and changing correctly. The final step would be to make it delay until a button is pressed.

    By the way, when I say "counters" I'm not using it in a technical sense, but rather in an colloquial sense. It isn't really an official term, it's just a reference to the way a variable is used.

    For some nice code examples, I'd look in the Stamps in Class forum, specifically at the posts from Parallax employees. They have posted quite a few "mini-labs" with code and discussions about the code. They're quite good.

    
    letter VAR Byte
    lcd_pin PIN 1
    lcd_baud CON 84
    
    FOR letter = 65 TO 90
      SEROUT lcd_pin, lcd_baud, [noparse][[/noparse]letter]
    NEXT
    
    
  • ihmechihmech Posts: 179
    edited 2009-09-13 16:00
    Hey, that gives me a good start! Thank you very much!
  • ihmechihmech Posts: 179
    edited 2009-09-14 12:24
    SRLM said...
    The code below should get you started. I don't have the hardware with me to test it, but it should print out the A to Z on the LCD. The next step would be to modify it to print out the letters at the same spot on screen. To do that you'll need to figure out the appropriate commands from the LCD datasheet. They should be within the first forty or so commands. You'll also need to add a pause in there to slow things down so you can actually confirm that the letters are appearing and changing correctly. The final step would be to make it delay until a button is pressed.
    
    letter VAR Byte
    lcd_pin PIN 1
    lcd_baud CON 84
    
    FOR letter = 65 TO 90
      SEROUT lcd_pin, lcd_baud, [noparse][[/noparse]letter]
    NEXT
    
    


    SRLM, thank you much for the code!· I tried the code you supplied and it worked great.· Within an hour,·I figured out how to use scroll through the code with one push button and then two push buttons.· I went further with it and decided that I wanted to incorperate 0 to 9 in the character selection.· I ended up using the LOOKUP command and listing the desired characters from my ASCII chart so I would not have to scroll through all of the characters between 9 and A.· I don't know if its the best way to do what I was wanting, but it works really well.· I figure I can make improvements in my code in the future when I have more understanding.

    Thanks to everyone for the help!!cool.gif
  • SRLMSRLM Posts: 5,045
    edited 2009-09-14 14:09
    To avoid the memory waste that a look up has, you can add a pair of if statements that tests for Z+1 (in which case it goes to 0) or 9+1 (in which case it goes to A).

    I'm glad you got it working.
  • ihmechihmech Posts: 179
    edited 2009-09-14 22:55
    Thanks for the tip, I will try it out. I just bought a BS2e because I was afraid of running out of space and also would like to have code in different "slots" to save trouble in updating or adding features in the future. I'm going to put up a new post on the BS2e for tips in using.

    Thanks for the help!
Sign In or Register to comment.