How to get numbers from LCD Terminal AppMod to BS2pe! Thanks!!!
nowhateve
Posts: 8
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"]
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"]
Comments
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.
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?
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.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
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).
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
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.