Shop OBEX P1 Docs P2 Docs Learn Events
split a SERIN string in to two varibles? — Parallax Forums

split a SERIN string in to two varibles?

AllexAllex Posts: 1
edited 2010-10-17 14:17 in BASIC Stamp
Hi all!
iam new to the BasicStamp and need some help whit this.

how can i split a incomming string from the serin command? this is my incomming "15#1100" i have used # as separator.

i whant to put 15 in VAR Servo and the value after # in to VAR ServoP.

BS2:
counter VAR Byte
Servo VAR Word
ServoP VAR Word
PAUSE 1000

Main:
SERIN 16, 16572,15,timeout,[Servo , ServoP]
timeout:
IF Servo ="1" THEN
Servo = 0
GOTO CENTER
ENDIF
GOTO Main

Servo:

FOR counter = 1 TO 50
PULSOUT Servo, ServoP
PAUSE 20
NEXT
GOTO Main
RETURN
_____________
//Alex

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2010-10-17 14:17
    Have a look in the Help file of the editor under SERIN.

    You should be able to grab the first number, skip the # and then grab the next number.

    Take note of how the data is interpreted so as not to confuse the ASCII character for a number with the actual value of the number.

    You don't mention whether you've actually got data arriving at the Stamp. I usually set up a very short loop with only the SERIN command and an LED which gets triggered if the SERIN actually sees some characters.
Sign In or Register to comment.