|
Post by stan58 on Jan 28, 2019 7:58:53 GMT -5
I can read ASC11 characters from the serial port , but I now need to read a transmision consisting of up to three bytes of binary data, how can I convert this to the data string obtained from the ASC11 transmission ?
|
|
|
Post by mknarr on Jan 28, 2019 14:17:01 GMT -5
Assuming you mean you will have a binary number that looks like this 101 and want to convert it to a number you could do this. This will work fo a binary number of any length.
B$="101" L=len(B$) Number=0 for x=1 to L bit$=mid$(B$,L-(x-1),1) ans=val(bit$) if ans=1 then ans=2^(x-1) Number=Number+ans end if next print Number
|
|
|
Post by mknarr on Jan 28, 2019 14:20:08 GMT -5
Sorry for the double post
|
|
|
Post by tsh73 on Jan 29, 2019 3:46:24 GMT -5
|
|
|
Post by stan58 on Jan 30, 2019 14:26:12 GMT -5
Thanks mknar Question answered tsh73 thanks for your advice.
|
|