BASIC Stamp Variables
CorbettROV
Posts: 17
Hi, I need to have my BS2 set a variable to zero if it does not hear from the computer for a certain amount of time. How do I do that?
Comments
[noparse][[/noparse]quote]
' {$STAMP BS2}
' {$PBASIC 2.5}
x VAR Byte
y VAR Byte
z VAR Byte
DO
SEROUT 0, 84, [noparse][[/noparse]z, x]
DEBUGIN y
IF (y=97) THEN
z=$C6
x=127
ELSEIF (y=115) THEN
z=$C5
x=127
ENDIF
LOOP
Use the timeout feature as described in the Manual chapter on the SERIN statement. If the timeout occurs, set x to 0.
This has some limitations. In particular, if the Debug Terminal sends a character while the Stamp program is doing
something else (than the DEBUGIN or SERIN), the Stamp will miss the character.
What would I set as the baud rate?
And if I use SERIN instead of DEBUGIN, would the debug terminal come up?
As far as I know, the Stamp Editor just detects incoming characters and that causes the debug terminal to start.
Don't forget the timeout time and label.
··· DEBUG CR
in your Stamp program, and Debug will start in the PC.· Then you can type stuff in.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i
Thanks
Post Edited (CorbettROV) : 10/30/2008 10:08:20 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There are 10 types of people that understand binary, those who do, and those who don't.
Thanks, I'll test this out Monday.
The last thing done in the loop is to set x to zero. It's always done.
Why do you have a parity error label when you've specified no parity? Read the SERIN description again.
At a minimum, you need to put a GOTO after the ENDIF that goes to just before the LOOP
I want it to go to "Continue" if it gets a y value and if it times out, i\I want it to go to "Time_Out". It's not working though.
Thanks