We are attempting to read in value from a tilt sensor for an auto stabilizing hover platform, but ran into a bit of a problem when the sensor only sends us 1 byte of the signal at a time in this format:
Byte3: X-axis tens digit of angle value
Byte4: X-axis ones digit of angle value
Byte5:"." (decimal point)
Byte6: one digit after decimal of X-axis angle value
Byte7: 20 (appears as a blank space)
Byte8: 20 (appears as a blank space)
Byte11: Y-axis tens digit of angle value
Byte12: Y-axis ones digit of angle value
Byte13: "." (decimal point)
Byte14: one digit after decimal of Y-axis angle value
Byte16: 0a (tilt sensor schematic says these are the last two bits but never saw them come through... the schematic also labeled the data output pin wrong so it is not to be trusted)
We can't figure out an efficient way to take these single bits and condense them into something consistent that we can use like X -05.3 if the angle is -5.3 degrees.
We tried making code that would detect the X bit and read in the next 15 or so bytes but it was pretty inefficient by the time it worked correctly, and it still didn't string together the read in bits so we could actually use them. Could really use some help, and appreciate any we can get.
Thanks for taking the time to read this post