Shop OBEX P1 Docs P2 Docs Learn Events
BASIC Stamp 2 interaction — Parallax Forums

BASIC Stamp 2 interaction

ilyailya Posts: 13
edited 2008-03-31 22:14 in BASIC Stamp
I am trying to have one BASIC Stamp communicate with another. I need one Stamp to send out a variable named "ActualAngleDegr" which is an 8 bit variable. I need the other stamp to read this variable and use it in a set of logical commands. I have been trying to use the SERIN and SEROUT commands but the variable has not been transmitting. The code for the Stamp that sends the variable is (I only included the actual line that should send the variable):

SEROUT 5, 396, [noparse][[/noparse]DEC3 ActualAngleDegr]

The code for the Stamp that receives the variable is (I only included the lines that input the variable and display it):

ActualAngleDegr VAR Word

SERIN 0, 396, [noparse][[/noparse]ActualAngleDegr]

DEBUG MoveTo, 0, 3, "ActualAngleDegr is: ", ActualAngleDegr, " "

When the two Stamps are run the debug screen opens but no text appears. Any thoughts or suggestions? Thanks.

-Ilya

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-31 21:24
    When you use DECn on one end of the "conversation", you need it on both ends. It may be useful to use a "lead-in" character and maybe a terminator like this:

    SEROUT 5,396,[noparse][[/noparse]"!", DEC ActualAngleDegr, ";"]

    SERIN 0,396,[noparse][[/noparse]wait("!"), DEC ActualAngleDegr]

    The receiving Stamp will see the non-digit character after the number and use that to mark the end of the numeric value.
  • ilyailya Posts: 13
    edited 2008-03-31 22:14
    The second Stamp is still not receiving the data. I have simplified the code for the second Stamp as:

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    ActualAngleDegr VAR Word
    MoveTo CON 2

    SERIN 0,396,[noparse][[/noparse]WAIT("!"), DEC ActualAngleDegr]

    DEBUG MoveTo, 0, 3, "ActualAngleDegr is: ", ActualAngleDegr, " "

    Yet it does not write anything when the debug screen opens. I know the first stamp writes a number to the variable ActualAngleDegr. Could the problem be that the first Stamp is not transmitting the variable correctly or at all? Thanks.
Sign In or Register to comment.