- Fri Apr 20, 2018 11:26 pm
#75529
Ok, perhaps the value was merely drifting between attempts and I happened to get 1 at times I tried sending binary data.
Some new trials, this time dealing with the whole 16-bit value as 2 bytes:
Code: Select all> a=adc.read(0)
> uart.write(0, a/256, a%256)
00 00 3E 20
> a=adc.read(0)
> uart.write(0, a/256, a%256)
00 01 3E 20
>
So perhaps there is no issue here after all, aside from noting that this works for an integer firmware build and if you use a float build you'll probably want to use:
Code: Select all> uart.write(0, math.floor(a/256), a%256)
.. unless somebody knows that the conversion to Byte values always handles that. I haven't experimented yet with a float build or I'd test it myself.