I have been reading several threads but I am still not sure how to accomplish this. I am reading some values in Arduino with analogRead(), so I am getting values between 0-1023 and I am sending them to Matlab via Serial Communiaction. I am currently using Serial.print(), but I have read that it is a much more efficient way to use Serial.write(): by packing first the value into bits and only sending the MSB and the LSB. This way I will use less bits to send one value than in the case of using Serial.print.
The thing is that I don't know how I can pack the values (0-1023) in Arduino to send the MSB and LSB and then unpacking them in MATLAB to define the integer value again.
Coud you please give me a hand?
Thanks in advance