Shop OBEX P1 Docs P2 Docs Learn Events
Send a variable with shiftout- question — Parallax Forums

Send a variable with shiftout- question

ArchiverArchiver Posts: 46,084
edited 2003-12-15 22:57 in General Discussion
I have a variable like:

Number Var Byte ' (0-255)

Then, sometimes I need to clock out the value in variable 'Number'
with SHIFTOUT sdo,sck,MSBFIRST,[noparse][[/noparse]DataOut\8]

But DataOut is always a string-byte-number.
How convert a variable number e.g. 123 to strigvalue 1,2 and 3?

Stein

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-12-15 22:49
    Hi Stein,

    Try this:

    SHIFTOUT sdo,sck,MSBFIRST,[noparse][[/noparse](Number DIG 2) + 48, (Number DIG 1) + 48, (Number
    DIG 0) + 48]

    The DIG operator returns the specified decimal digit of a positive value.
    Adding 48 to the result simply converts the decimal digit to its ASCII
    value.

    I hope this helps.

    Best regards,

    Russell Warburton
    email: russell@w...
    website: http://www.warburtech.com
    telephone: +44 (0)7814 044 754
    Original Message
    From: "
  • ArchiverArchiver Posts: 46,084
    edited 2003-12-15 22:57
    I try it.
    I think this will work.

    Thanks.

    --- In basicstamps@yahoogroups.com, "Russell Warburton"
    <russell@w...> wrote:
    > Hi Stein,
    >
    > Try this:
    >
    > SHIFTOUT sdo,sck,MSBFIRST,[noparse][[/noparse](Number DIG 2) + 48, (Number DIG 1) +
    48, (Number
    > DIG 0) + 48]
    >
    > The DIG operator returns the specified decimal digit of a positive
    value.
    > Adding 48 to the result simply converts the decimal digit to its
    ASCII
    > value.
    >
    > I hope this helps.
    >
    > Best regards,
    >
    > Russell Warburton
    > email: russell@w...
    > website: http://www.warburtech.com
    > telephone: +44 (0)7814 044 754
    >
    Original Message
    > From: "
Sign In or Register to comment.