Send a variable with shiftout- question
Archiver
Posts: 46,084
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
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
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: "
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: "