Hi,
I'm having an issue with the byte order changing after a while of use.
This works great for a while, then it shows some unexpected vlaues.
Output below a sequense from using the BT slide. It shows the
expected values, then the next set of bytes are all wrong ... seem as the byte order is reversed.
Using HC-06 on arduino UNO
Used MIT App Inventor:

maxvalue: 1180
minvalue: 1000
*note: bluetooth client has 'HighByteFirst" checked.
Here is the code to see the data:
#include <SoftwareSerial.h>
int bluetoothTx = 4;
int bluetoothRx = 5;
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup()
{
bluetooth.begin(9600);
}
void loop()
{
//Read from bluetooth
if(bluetooth.available()>= 2 )
{
unsigned int msbyte = bluetooth.read();
unsigned int lsbyte = bluetooth.read();
Serial.print("MSbyte: ");Serial.println(msbyte);
delay(10);
Serial.print("LSbyte: ");Serial.println(lsbyte);
delay(10);
unsigned int numsent = (msbyte *256) + lsbyte;
Serial.print("Num-sent: ");Serial.println(numsent);
delay(10);
}
}
Output:
MSbyte: 4
LSbyte: 10
Num-sent: 1034 ... expected
MSbyte: 4
LSbyte: 8
Num-sent: 1032 ... expected
MSbyte: 4
LSbyte: 7
Num-sent: 1031 ... expected
MSbyte: 4
LSbyte: 3
Num-sent: 1027 ... expected
MSbyte: 254
LSbyte: 3
Num-sent: 65027 ... not expected
MSbyte: 245
LSbyte: 3
Num-sent: 62723 ... not expected
MSbyte: 248
LSbyte: 4
Num-sent: 63492 ... not expected
MSbyte: 14
LSbyte: 4
Num-sent: 3588 ... not expected
MSbyte: 35
LSbyte: 4
Num-sent: 8964 ... not expected
Any ideas why this is happening?
Thx,
Ron