problems with values when converting with STR
Andreas
Posts: 3
I realy need your help. I want to take my value from my SerString1 and put·it in my "SEROUT 15, ServoBaud+$8000,[noparse][[/noparse]"!SC", 11, 1, pw.LOWBYTE, pw.HIGHBYTE,CR]" as "pw". How do I make this work? I can see the value correct in "SEROUT Port,Baud,[noparse][[/noparse]" NR1: ", STR SerString1]
" but when I try to "convert" it into "pw.LOWBYTE and pw.HIGHBYTE its not working anymore. Can you please help me=
' {$STAMP BS2}
' {$PBASIC 2.5}
pw VAR Word
ServoBaud CON 396
Baud CON 16780
Port CON 16
SerString1 VAR Byte(6)
SerString1(9)=0
SerString2 VAR Byte(6)
SerString2(9)=0
SerString3 VAR Byte(6)
SerString3(9)=0
SEROUT Port, Baud, [noparse][[/noparse]"Welcome"]
GOSUB sound_0:
PAUSE 100
Main:
SERIN Port,Baud,Main,2000,Main, [noparse][[/noparse]WAIT ("coord"), STR SerString1\5\"*", STR SerString2\5\"*", STR SerString3\5\"*"]
'PAUSE 100
SEROUT Port,Baud,[noparse][[/noparse]" NR1: ", STR SerString1]
SEROUT Port,Baud,[noparse][[/noparse]" NR2: ", STR SerString2]
SEROUT Port,Baud,[noparse][[/noparse]" NR3: ", STR SerString3]
PAUSE 1000
'Servo1
SEROUT 15, ServoBaud+$8000,[noparse][[/noparse]"!SC", 11, 1, pw.LOWBYTE, pw.HIGHBYTE,CR]
GOTO Main
sound_0:
········ FREQOUT spkr,1000,2000
RETURN
" but when I try to "convert" it into "pw.LOWBYTE and pw.HIGHBYTE its not working anymore. Can you please help me=
' {$STAMP BS2}
' {$PBASIC 2.5}
pw VAR Word
ServoBaud CON 396
Baud CON 16780
Port CON 16
SerString1 VAR Byte(6)
SerString1(9)=0
SerString2 VAR Byte(6)
SerString2(9)=0
SerString3 VAR Byte(6)
SerString3(9)=0
SEROUT Port, Baud, [noparse][[/noparse]"Welcome"]
GOSUB sound_0:
PAUSE 100
Main:
SERIN Port,Baud,Main,2000,Main, [noparse][[/noparse]WAIT ("coord"), STR SerString1\5\"*", STR SerString2\5\"*", STR SerString3\5\"*"]
'PAUSE 100
SEROUT Port,Baud,[noparse][[/noparse]" NR1: ", STR SerString1]
SEROUT Port,Baud,[noparse][[/noparse]" NR2: ", STR SerString2]
SEROUT Port,Baud,[noparse][[/noparse]" NR3: ", STR SerString3]
PAUSE 1000
'Servo1
SEROUT 15, ServoBaud+$8000,[noparse][[/noparse]"!SC", 11, 1, pw.LOWBYTE, pw.HIGHBYTE,CR]
GOTO Main
sound_0:
········ FREQOUT spkr,1000,2000
RETURN
Comments
It's not quite clear what you want to do, but take a look at this. I may or may not have a picture of what you want to do:
Main:
SERIN Port,Baud,Main,2000,Main, [noparse][[/noparse]WAIT ("coord"), STR SerString1\5\"*", STR SerString2\5\"*", STR SerString3\5\"*"]
'PAUSE 100
SEROUT Port,Baud,[noparse][[/noparse]" NR1: ", STR SerString1]
SEROUT Port,Baud,[noparse][[/noparse]" NR2: ", STR SerString2]
SEROUT Port,Baud,[noparse][[/noparse]" NR3: ", STR SerString3]
PAUSE 1000
pw.HIGHBYTE=SerString1(0)
pw.LOWBYTE=SerString1(1)
'Servo1
SEROUT 15, ServoBaud+$8000,[noparse][[/noparse]"!SC", 11, 1, pw.LOWBYTE, pw.HIGHBYTE,CR]
GOTO Main
Parenthetically, the constant "spkr" is presently undefined in the program you posted.
Regards,
Bruce Bates