Shop OBEX P1 Docs P2 Docs Learn Events
pink help needed to read variable into BS2 — Parallax Forums

pink help needed to read variable into BS2

MososkiMososki Posts: 3
edited 2006-04-12 07:59 in BASIC Stamp
I'm trying to read a variable (integer ex: 131) from the pink into the BS2.· I'm used the example shown in the PINK manual on page 8 and all I get is the code (49) for the first digit (1).· How can I get all three digits into a BS2 variable?· Here's a copy of what I'm using:

Mark


nbvar· VAR Byte(16)
SEROUT 8,396,[noparse][[/noparse]"!NB0R06"]
SERIN 9,396,[noparse][[/noparse]nbvar]
DEBUG DEC nbvar

Comments

  • SSteveSSteve Posts: 808
    edited 2006-04-12 07:59
    I think you need to do this:

    SERIN 9,396,[noparse][[/noparse]STR nbvar\3]

    to get three bytes (but I haven't played with SERIN yet, so I'm not 100% sure).

    Then, assuming the most significant byte is received first, the statement "value = ((nbvar(0) - "0") * 100) + ((nbvar(1) - "0") * 10) + (nbvar(2) - "0")" will convert the three-digit BCD value into a binary value.

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