Basic Help needed!
I'm just beginning to learn the basics of programming the basic stamp 2.
My first testprogram is working great, although the second is not working, i hope someone can help me with this one!
First the program that works:
' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM13}
inFromSerialVar VAR Byte
Main:
· SERIN 7, 16468, [noparse][[/noparse]inFromSerialVar]
· IF inFromSerialVar THEN
··· GOSUB LightA:
· ENDIF
GOTO main
LightA:
HIGH 8
PAUSE 1000
LOW 8
RETURN
Now i want the code to check a incomming var like "A"(ASCII=65) and "B" (ASCII=66) then the function lightA or lightB should follow.
but i cant get the next code working:
' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM13}
serData·· VAR···· Byte
Main:
· SEROUT 6, 16468, [noparse][[/noparse]"A"]
· SERIN 1, 16780, [noparse][[/noparse]WAIT("123"), DEC serData]
· DEBUG ? serData
· IF serData THEN
······ GOSUB LichtAan
· ENDIF
GOTO main
LichtAan:
HIGH 8
PAUSE 1000
LOW 8
RETURN
now the serial input is correct ( i monitor it with a port monitor app)·<!--StartFragment -->
the input now is correct:·A123AB (ASCII 41 31 32 33 41 42)·
i hope someone will help me.
Martijn
My first testprogram is working great, although the second is not working, i hope someone can help me with this one!
First the program that works:
' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM13}
inFromSerialVar VAR Byte
Main:
· SERIN 7, 16468, [noparse][[/noparse]inFromSerialVar]
· IF inFromSerialVar THEN
··· GOSUB LightA:
· ENDIF
GOTO main
LightA:
HIGH 8
PAUSE 1000
LOW 8
RETURN
Now i want the code to check a incomming var like "A"(ASCII=65) and "B" (ASCII=66) then the function lightA or lightB should follow.
but i cant get the next code working:
' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM13}
serData·· VAR···· Byte
Main:
· SEROUT 6, 16468, [noparse][[/noparse]"A"]
· SERIN 1, 16780, [noparse][[/noparse]WAIT("123"), DEC serData]
· DEBUG ? serData
· IF serData THEN
······ GOSUB LichtAan
· ENDIF
GOTO main
LichtAan:
HIGH 8
PAUSE 1000
LOW 8
RETURN
now the serial input is correct ( i monitor it with a port monitor app)·<!--StartFragment -->
the input now is correct:·A123AB (ASCII 41 31 32 33 41 42)·
i hope someone will help me.
Martijn
Comments
My final code is now:
' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM13}
serData VAR Byte
Main:
SEROUT 6, 16468, [noparse][[/noparse]"A"]
SERIN 7, 16780, [noparse][[/noparse]WAIT("123"), serData]
IF serData = 65 THEN
GOSUB LichtAan
ENDIF
GOTO main
LichtAan:
HIGH 8
PAUSE 1000
LOW 8
RETURN
Although i think the IF line is not good. The code is also not working.. Is the line: IF serData = 65 THEN.... correct??
Thanks for helping me, i really appreciate it!
martijn
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
I see you have serout on P6 at 9600 and serin on P7 at 2400 both inverted (the earlier program had serin on P1 now P7 maybe a typo or a change)
Depending on what you have connected you may need serin at 2400 true which would be a baud rate of 396.
Jeff T.
Unsoundcode;·Off course! i didnt change the baud rate and focus to much on the function. I'm sorry for the lack of that. It works now great and i can go further with my project, Thanks for your help! Martijn