dakota77
01-06-2006, 05:34 AM
Hello,
From a Pocket Pc connected to BS2p I send the string "40A"
In the Basic Stamp I'd like to retrieve the value 40 and store it in variable x
Then do a calculation on x: y=x * 2
So I want to get the number 80.
In the program below :
The DEBUG 1) displays 40 (DEC x)
The DEBUG 2) displays P (ASCII code 80 = P)
How can I retrieve 40 as a number and then do operation on it ?
Thanks for your help.
main:
SERIN 7,16624,[DEC x]
IF x>0 THEN rel2
GOTO main
rel2:
DEBUG "1) DEC x = ",DEC x,CR
y=x*2
DEBUG "2) y = ",y
GOTO main
In the BS manual it's written :
"DEC tells SERIN to convert incoming text representing decimal numbers into true-decimal form and store the result in serdata. Afterwards, the program can perform any numeric operation on the number just like any other number."
From a Pocket Pc connected to BS2p I send the string "40A"
In the Basic Stamp I'd like to retrieve the value 40 and store it in variable x
Then do a calculation on x: y=x * 2
So I want to get the number 80.
In the program below :
The DEBUG 1) displays 40 (DEC x)
The DEBUG 2) displays P (ASCII code 80 = P)
How can I retrieve 40 as a number and then do operation on it ?
Thanks for your help.
main:
SERIN 7,16624,[DEC x]
IF x>0 THEN rel2
GOTO main
rel2:
DEBUG "1) DEC x = ",DEC x,CR
y=x*2
DEBUG "2) y = ",y
GOTO main
In the BS manual it's written :
"DEC tells SERIN to convert incoming text representing decimal numbers into true-decimal form and store the result in serdata. Afterwards, the program can perform any numeric operation on the number just like any other number."