Shop OBEX P1 Docs P2 Docs Learn Events
Basic Stamp SEROUT Help — Parallax Forums

Basic Stamp SEROUT Help

jkdalexjkdalex Posts: 8
edited 2006-06-01 22:09 in BASIC Stamp
Hi, I am new with basic stamp and I was wondering if someone could answer two questions for me -

1) I want to output the sequence·137 0 255 128 0 (5 seperate numbers) to a Roomba which recognizes them individually.· However, the only·way that works for me is·-

SEROUT Tpin, BMode_TX, [noparse][[/noparse]137]
SEROUT Tpin, BMode_TX, [noparse][[/noparse]0]
SEROUT Tpin, BMode_TX, [noparse][[/noparse]255]
SEROUT Tpin, BMode_TX, [noparse][[/noparse]128]
SEROUT Tpin, BMode_TX, [noparse][[/noparse]0]

Is there a more concise way of writing this? (assuming I am communicating at correct Tpin and BMode_TX inititalized already)

2) I also want to be able to write a program that takes an inputted key to make a decision.· Instead of using numbers to denote my selection, I would like to use characters.

If my code is this - SERIN RPin, BMode_RX, MaxTime, Timeout, [noparse][[/noparse]Choice]· and choice holds the character selection, what type should I declare "choice" as?

Thank you for your time and efforts!· It is much appreciated.
·

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-06-01 19:47
    Hello,
    ·· You could try it this way:
    SEROUT Tpin, BMode_TX, [noparse][[/noparse]137, 0, 255, 128, 0]
    

    If that is not working, but the other way is, then it would seem the data is going to fast for the receiving device.· If that's the case then you could use a pacing value to slow it down a bit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • jkdalexjkdalex Posts: 8
    edited 2006-06-01 20:08
    Thank you for your reply.· I was wondering about the second question - I have read appendix C in the basic stamp code and it seems that the only characters the basic stamp can accept is from A-F.

    I would like to be able to implement the following code -

    Choice VAR Word
    DEBUG CLS,"Which direction would you like to go?",CR
    DEBUG "[noparse][[/noparse]F]orward, [noparse][[/noparse]B]ack, [noparse][[/noparse]L]eft, [noparse][[/noparse]R]ight, [noparse][[/noparse]S]top",CR, ">> "· ' Request Choice
    SERIN RPin, BMode_RX, MaxTime, Timeout, [noparse][[/noparse]Word Choice] ' Await serial data

    But it won't accept a character (i.e. 'R') for "Choice".· What type of variable should I declare Choice to be and how should I change my code?

    All the SERIN documentation seems to use DEC as the argument but I would like to use something besides numbers.

    Thank you [noparse]:)[/noparse]
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-06-01 20:27
    jkdalex -

    Just define it as a BYTE like this:

    Choice VAR Byte
    DEBUG CLS,"Which direction would you like to go?",CR
    DEBUG "[noparse][[/noparse]F]orward, [noparse][[/noparse]B]ack, [noparse][[/noparse]L]eft, [noparse][[/noparse]R]ight, [noparse][[/noparse]S]top",CR,">>"
    SERIN RPin, BMode_RX, MaxTime, Timeout, [noparse][[/noparse]Choice>]

    Then set up a SELECT CASE Statement:

    Select Choice

    Case = "F" or "f"
    ...
    Case = "B' or "b"
    ...

    etc.

    Regards,

    Bruce Bates


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->

    Post Edited (Bruce Bates) : 6/1/2006 8:34:57 PM GMT
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-06-01 20:36
    Help!

    If anyone can remove the overstrikes from this last post, PLEASE do so! I have NO IDEA how they got in there.

    I even tried changing the entire text letter-by-letter, but STILL couldn't remove them!

    Web posting BYTES!

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • SSteveSSteve Posts: 808
    edited 2006-06-01 22:09
    Bruce, the strikeouts are caused by an S contained in square brackets (and the bold from a B contained in square brackets). If you enclose the code in [noparse][[/noparse]*code] [noparse][[/noparse]*/code] (without the asterisks), it should display correctly. Without the code tag, things in square brackets will be interpreted as formatting tags.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows
Sign In or Register to comment.