BS2sx
leshea2
Posts: 83
How would I add another line of code to this command, if I want to make the BS2sx stamp flash an LED on and off once, to confirm the this part of the code,
Send_Msg:
DO
READ eePntr, char
eePntr = eePntr + 1
IF (char = 0) THEN EXIT
SEROUT Sout, Baud, [noparse][[/noparse]char]
LOOP
RETURN
was successful executed ?
Thanks !
' {$STAMP BS2sx}
' {$PBASIC 2.5}
Sout PIN 0
Baud CON 17405
eePntr VAR Word
char VAR Byte
Msg1 DATA "Call 18004459889 at 4:35 p.m.", 0
Main:
eePntr = Msg1
GOSUB Send_Msg
END
Send_Msg:
DO
READ eePntr, char
eePntr = eePntr + 1
IF (char = 0) THEN EXIT
SEROUT Sout, Baud, [noparse][[/noparse]char]
LOOP
RETURN
Send_Msg:
DO
READ eePntr, char
eePntr = eePntr + 1
IF (char = 0) THEN EXIT
SEROUT Sout, Baud, [noparse][[/noparse]char]
LOOP
RETURN
was successful executed ?
Thanks !
' {$STAMP BS2sx}
' {$PBASIC 2.5}
Sout PIN 0
Baud CON 17405
eePntr VAR Word
char VAR Byte
Msg1 DATA "Call 18004459889 at 4:35 p.m.", 0
Main:
eePntr = Msg1
GOSUB Send_Msg
END
Send_Msg:
DO
READ eePntr, char
eePntr = eePntr + 1
IF (char = 0) THEN EXIT
SEROUT Sout, Baud, [noparse][[/noparse]char]
LOOP
RETURN
Comments
Success:
· HIGH Led
· PAUSE 100
· LOW Led
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
' {$STAMP BS2sx}
' {$PBASIC 2.5}
Sout PIN 0
Baud CON 17405
eePntr VAR Word
char VAR Byte
Msg1 DATA "Call 18004459889 at 4:35 p.m.", 0
Main:
eePntr = Msg1
GOSUB Send_Msg
END
Send_Msg:
DO
READ eePntr, char
eePntr = eePntr + 1
IF (char = 0) THEN EXIT
SEROUT Sout, Baud, [noparse][[/noparse]char]
LOOP
RETURN
HIGH Led
PAUSE 100
LOW Led
END
HIGH Led
PAUSE 100
LOW Led
is never executed since the above function has been RETURNed from and the code never jumps to the LED flashing code. Additionally you have not specified which pin Led is defined as. Either create a new subroutine and GOSUB to it after you've "GOSUB Send_Msg" or just place the code itself after GOSUB Send_Msg, or place the code before the RETURN. Somewhere the execution of your program·must flow through the commands in order for them to be performed, what you have done is created a "dead code" section, meaning you have valid code that is never called or executed.
You seem to be fundamentally confused on some basic aspects of programming, Please read "What's a Microcontroller" in the Downloads>Stamps In Class section. It is a primer on using the basic stamp and covers alot of the fundamental topics you are confused about.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Post Edited (Paul Baker) : 8/17/2005 10:34:58 PM GMT
' {$STAMP BS2sx}
' {$PBASIC 2.5}
Sout PIN 0
Baud CON 17405
eePntr VAR Word
char VAR Byte
Msg1 DATA "Call 18004459889 at 4:35 p.m.", 0
Main:
eePntr = Msg1
GOSUB Send_Msg
END
Send_Msg:
DO
READ eePntr, char
eePntr = eePntr + 1
IF (char = 0) THEN EXIT
SEROUT Sout, Baud, [noparse][[/noparse]char]
LOOP
HIGH 0
PAUSE 1000
LOW 0
PAUSE 1000
END
Jon and I have been bumping heads answering the question, we kept editing our two posts simulataneously adding the same info, anyways to recap (since the post has been edited and Jon has since removed his).
This code should work:
' {$STAMP BS2sx}
' {$PBASIC 2.5}
Sout PIN 0
Led· PIN 2
Baud CON 17405
eePntr VAR Word
char VAR Byte
Msg1 DATA "Call 18004459889 at 4:35 p.m.", 0
Main:
eePntr = Msg1
GOSUB Send_Msg
END
Send_Msg:
DO
READ eePntr, char
eePntr = eePntr + 1
IF (char = 0) THEN EXIT
SEROUT Sout, Baud, [noparse][[/noparse]char]
LOOP
HIGH Led
PAUSE 100
LOW Led
RETURN
END
place your LED on pin 2 or redefine the pin in the code.
Also Jon suggested using·"DEBUG char"·function in place of··"SEROUT Sout, Baud, [noparse][[/noparse]char]", this will output the data to your debug terminal instead of the serial line thereby verifying the data would be sent correctly on the serial line.
<EDIT> Your adjusted code doesn't have a return anymore, the code will work, but it is not good programming practice to not RETURN from a GOSUB </EDIT>
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
P.S.
Can I use GOTO main: instead of RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax