Shop OBEX P1 Docs P2 Docs Learn Events
How to get numbers from LCD Terminal AppMod to BS2pe! Thanks!!! — Parallax Forums

How to get numbers from LCD Terminal AppMod to BS2pe! Thanks!!!

nowhatevenowhateve Posts: 8
edited 2008-11-28 21:51 in BASIC Stamp
I am using BS2pe to program a timer and have managed to make the LCD display the time counting down.(say from 01:25 to 00:00).
I also want to set the timer through the LCD. Three are four buttons on the LCD and according to the instruction manual, I should be able to do that. I looked up the sample code but it is way too complicated to me.
What I have done is posted below: I guess the chip should get input(the NUMBER OF SECONDS) from the LCD and store it in the variable B1, which is currently a constant in my program.


Lcd PIN 1
LcdCls CON $01
C1 VAR Byte


Init_LCD:
PAUSE 1000
LCDCMD Lcd, %00110000
PAUSE 5
LCDCMD Lcd, %00110000
PAUSE 0
LCDCMD Lcd, %00110000
PAUSE 0
LCDCMD Lcd, %00100000
LCDCMD Lcd, %00101000
LCDCMD Lcd, %00001100
LCDCMD Lcd, %00000110


Main:
B1=121
C1=B1/60
B1=B1-(C1*60)
DO UNTIL((B1=0) AND (C1=0))
LCDOUT Lcd, LcdCls, [noparse][[/noparse]"0",DEC C1,":",DEC B1]
PAUSE 1000
IF ((B1=0)AND(C1<>0))THEN
B1=60
C1=C1-1
ENDIF
B1=B1-1

LOOP
LCDOUT Lcd, LcdCls, [noparse][[/noparse]"00:0"]
smilewinkgrin.gif

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-11-28 03:19
    nowhatev -

    My best suggestion is to go back to the original demo program supplied by Parallax, and work from there. There is way too much of the original program which has been stripped out, including the very valuable COMMENTS. In addition to that there are compiler directives that are missing, presuming you've shown us your entire program.

    In the future, please use the attachment manager if you want to have program code as a part of your message, rather than the in-line code which you have here. The "way too complicated" program code is an integral part of the program, and should never have been removed. Putting it back in would be more trouble that it's worth. Starting from scratch with the demo program will be a much faster, and better way to go.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When all else fails, try inserting a new battery.
  • nowhatevenowhateve Posts: 8
    edited 2008-11-28 03:40
    Thanks for your reply,Bruce. You advice is helpful to me, a newcomer.
    I have attached the codes I have written and the demo code from PARALLAX.
    My code is all out LCD output and the demo code pays attention to how to get input from LCD. This is my first Basic Stamp project and am really lost....

    I dont think my program needs to be so advanced. All I wanna achieve is that I type a number in the LCD and the chip reads it as the number of seconds, which is B1 in my code.
    Anyone could help?? Or just some hints?
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-11-28 03:48
    nowhateve -

    As far as I'm aware the ONLY input capablity that the LCD App Mod has are the pushbuttons. How were you planning to use those to input a number? To be honest, I didn't look at your program yet.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When all else fails, try inserting a new battery.
  • FranklinFranklin Posts: 4,747
    edited 2008-11-28 03:56
    You need to use the buttons to change the variable in the stamp and then display that on the LCD. The LCD is driven from the stamp not the other way. If it's displayed on the LCD it's already somewhere in the stamp code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • sylvie369sylvie369 Posts: 1,622
    edited 2008-11-28 11:35
    The LCD Appmod demo isn't as complicated as it looks, if you're using a 2p, 2pe, or 2px. All of those compiler directives can be ignored as can the complex code for the other chips that don't have the LCDCMD-type commands. I've attached a simpler demo (currently set up for a 2px, but should work with a 2pe if you change the $STAMP directive). All of the CONs and VARs may look daunting, but just look past them to the code first.

    To enter your number, you might have two of the pushbuttons increment and decrement the number from some starting point (save yourself some trouble and start from a likely value, rather than always from 0), with the current number displayed on the LCD. A third button could change the amount of increment/decrement, and the fourth button commit you to the number you've chosen. Your code could put up a short warning message if the user tries to change the number "out of bounds" (say, to a negative number, or above 255 for a byte variable).
  • nowhatevenowhateve Posts: 8
    edited 2008-11-28 19:11
    Thank you Sylvie369!

    I have a question regarding the syntax. What are DIRB, OUTB and INB in the following codes. Why do we need that?
    LcdDirs VAR DIRB
    LcdBusOut VAR OUTB
    LcdBusIn VAR INB
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-28 20:00
    Read the Manual in the section on Aliases and the section on Memory Allocation. You'll find that DIRx is equivalent to an I/O pin direction register bit or group of bits, OUTx is the equivalent for the output register, and INx is the equivalent for the input register. You can use the entire 16 bit register(s) or two 8-bit groups or four 4-bit groups (or individual bits) depending on the last character of the name.
  • allanlane5allanlane5 Posts: 3,815
    edited 2008-11-28 21:51
    The BS2 is based on a PIC chip. PIC chips allow you to set an I/O pin as Output (in which case you can Output a 1, or Output a zero) or an Input (in which case it's a High-Impedance resistance, reading whatever voltage some other driver has put on that pin).

    The DIR register is the one that allows you to select those "DIRections" (as Input or Output). I believe setting a bit to ZERO makes it an OUTPUT, but I'm not sure about that.

    You can set these in sets of 4 using DIRa, DIRb, DIRc, and DIRd. You write to OUTB to set the output state of 4 pins -- 4, 5, 6, and 7. You read from INB to read the state of those 4 pins, if it's set on INPUT, or whatever the output put on them, if it's set as OUTPUT.

    You need to set these if you're setting 4 bits at the same time, with a single OUTB = $F statement.
Sign In or Register to comment.