Serial Communication - Newbie Question
Archiver
Posts: 46,084
Hi,
i programmed a application with Macromedia Director. I send Integer
between 0-255 to BS2 - nothing happens:
My Code:
'{$STAMP BS2}
'{$PBASIC 2.0}
rpin con 16
bmode con 16468
maxtime con 10000
test var byte(3)
Main:
debug cls, "Input Number: ", CR
serin rpin,bmode,maxtime,timeout,[noparse][[/noparse]test]
debug CR, "Your Input: ",test
if test = "1" then an
if test = "2" then an1
if test = "3" then an2
if test = "4" then aus
if test = "5" then alles
pause 3000
goto main
timeout:
debug"Timeout", CR
pause 1000
goto main
an:
HIGH 0
goto main
an1:
HIGH 1
goto main
an2:
HIGH 2
goto main
aus:
low 0
low 1
low 2
goto Main
alles:
high 0
high 1
high 2
goto main
Ifi send a String, it works.
But i wan't to send a Integer. What must i change in the Code, if the
BS2 recieve Integer's???
Please help
Thx
i programmed a application with Macromedia Director. I send Integer
between 0-255 to BS2 - nothing happens:
My Code:
'{$STAMP BS2}
'{$PBASIC 2.0}
rpin con 16
bmode con 16468
maxtime con 10000
test var byte(3)
Main:
debug cls, "Input Number: ", CR
serin rpin,bmode,maxtime,timeout,[noparse][[/noparse]test]
debug CR, "Your Input: ",test
if test = "1" then an
if test = "2" then an1
if test = "3" then an2
if test = "4" then aus
if test = "5" then alles
pause 3000
goto main
timeout:
debug"Timeout", CR
pause 1000
goto main
an:
HIGH 0
goto main
an1:
HIGH 1
goto main
an2:
HIGH 2
goto main
aus:
low 0
low 1
low 2
goto Main
alles:
high 0
high 1
high 2
goto main
Ifi send a String, it works.
But i wan't to send a Integer. What must i change in the Code, if the
BS2 recieve Integer's???
Please help
Thx
Comments
serin rpin,bmode,maxtime,timeout,[noparse][[/noparse] DEC test ]
i'm trying to do the same thing with Director, but at the moment i
can't seem to get anything to transfer across, either direction
--- In basicstamps@yahoogroups.com, "plumpi1009" <gplanincic@p...>
wrote:
> Hi,
>
> i programmed a application with Macromedia Director. I send Integer
> between 0-255 to BS2 - nothing happens:
>
> My Code:
>
> '{$STAMP BS2}
> '{$PBASIC 2.0}
> rpin con 16
> bmode con 16468
> maxtime con 10000
> test var byte(3)
>
> Main:
> debug cls, "Input Number: ", CR
> serin rpin,bmode,maxtime,timeout,[noparse][[/noparse]test]
> debug CR, "Your Input: ",test
>
> if test = "1" then an
> if test = "2" then an1
> if test = "3" then an2
> if test = "4" then aus
> if test = "5" then alles
> pause 3000
> goto main
>
> timeout:
> debug"Timeout", CR
> pause 1000
> goto main
>
> an:
> HIGH 0
> goto main
> an1:
> HIGH 1
> goto main
> an2:
>
> HIGH 2
> goto main
> aus:
> low 0
> low 1
> low 2
> goto Main
>
> alles:
> high 0
> high 1
> high 2
> goto main
>
>
> Ifi send a String, it works.
>
> But i wan't to send a Integer. What must i change in the Code, if
the
> BS2 recieve Integer's???
>
> Please help
>
> Thx
can use the DEC modifier in SERIN to convert the string to a decimal
value:
SERIN Rpin, Bmode, MaxTime, Timeout, [noparse][[/noparse]DEC test]
By using DEC, "1" (ASCII value 49) will be converted to 1. You can
verify this is happening by doing a little test loop (which many users
see unwilling to do when troubles arise). Try this to see if the code
above will be valid:
Test:
SERIN Rpin, Bmode, MaxTime, Timeout, [noparse][[/noparse]test]
DEBUG DEC test
PAUSE 100
GOTO Test
If my assumption is correct, the Test code will display 49 when you have
Director send 1 to the BASIC Stamp.
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: plumpi1009 [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=kYQPGICupp7QxTsBguD3DCLskPkeYdG_5n-WwdIxNl-wpN1LRQ8V1etQIgS2PRtvD3-OTzX_mRs1alCIIZTgWNsW]gplanincic@p...[/url
Sent: Friday, April 16, 2004 8:30 AM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Serial Communication - Newbie Question
Hi,
i programmed a application with Macromedia Director. I send Integer
between 0-255 to BS2 - nothing happens:
My Code:
'{$STAMP BS2}
'{$PBASIC 2.0}
rpin con 16
bmode con 16468
maxtime con 10000
test var byte(3)
Main:
debug cls, "Input Number: ", CR
serin rpin,bmode,maxtime,timeout,[noparse][[/noparse]test]
debug CR, "Your Input: ",test
if test = "1" then an
if test = "2" then an1
if test = "3" then an2
if test = "4" then aus
if test = "5" then alles
pause 3000
goto main
timeout:
debug"Timeout", CR
pause 1000
goto main
an:
HIGH 0
goto main
an1:
HIGH 1
goto main
an2:
HIGH 2
goto main
aus:
low 0
low 1
low 2
goto Main
alles:
high 0
high 1
high 2
goto main
Ifi send a String, it works.
But i wan't to send a Integer. What must i change in the Code, if the
BS2 recieve Integer's???
Please help
Thx
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Yahoo! Groups Links
This message has been scanned by WebShield. Please report SPAM to
abuse@p....
got it.
Thx.
--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
wrote:
> Director may be sending your value as a string. If that's the
case, you
> can use the DEC modifier in SERIN to convert the string to a decimal
> value:
>
> SERIN Rpin, Bmode, MaxTime, Timeout, [noparse][[/noparse]DEC test]
>
> By using DEC, "1" (ASCII value 49) will be converted to 1. You can
> verify this is happening by doing a little test loop (which many
users
> see unwilling to do when troubles arise). Try this to see if the
code
> above will be valid:
>
> Test:
> SERIN Rpin, Bmode, MaxTime, Timeout, [noparse][[/noparse]test]
> DEBUG DEC test
> PAUSE 100
> GOTO Test
>
> If my assumption is correct, the Test code will display 49 when you
have
> Director send 1 to the BASIC Stamp.
>
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
>
>
>
Original Message
> From: plumpi1009 [noparse][[/noparse]mailto:gplanincic@p...]
> Sent: Friday, April 16, 2004 8:30 AM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] Serial Communication - Newbie Question
>
>
> Hi,
>
> i programmed a application with Macromedia Director. I send Integer
> between 0-255 to BS2 - nothing happens:
>
> My Code:
>
> '{$STAMP BS2}
> '{$PBASIC 2.0}
> rpin con 16
> bmode con 16468
> maxtime con 10000
> test var byte(3)
>
> Main:
> debug cls, "Input Number: ", CR
> serin rpin,bmode,maxtime,timeout,[noparse][[/noparse]test]
> debug CR, "Your Input: ",test
>
> if test = "1" then an
> if test = "2" then an1
> if test = "3" then an2
> if test = "4" then aus
> if test = "5" then alles
> pause 3000
> goto main
>
> timeout:
> debug"Timeout", CR
> pause 1000
> goto main
>
> an:
> HIGH 0
> goto main
> an1:
> HIGH 1
> goto main
> an2:
>
> HIGH 2
> goto main
> aus:
> low 0
> low 1
> low 2
> goto Main
>
> alles:
> high 0
> high 1
> high 2
> goto main
>
>
> Ifi send a String, it works.
>
> But i wan't to send a Integer. What must i change in the Code, if
the
> BS2 recieve Integer's???
>
> Please help
>
> Thx
>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the
Subject
> and Body of the message will be ignored.
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
> This message has been scanned by WebShield. Please report SPAM to
> abuse@p...