How will Serial.read() function read an integer value(say 1100) in Arduino?
"int" takes up 2 bytes of memory and read function reads only 1 byte at a time.
For following piece of code
unsigned int servopos=bluetooth.read(); //reads 1byte of data
unsigned int servopos1=bluetooth.read(); //reads 2nd byte
//unsigned int realservo=servopos1+servopos; this (statement1) gives ambiguous output
unsigned int realservo=servopos1*256+servopos; //I want to understand this line (statement2)
Here,"bluetooth" is an object of SoftwareSerial function,it reads up data from a bluetooth module which sends integer data between 1000 and 1180,
if suppose data is sent as value 1100 I want to receive the same data value 1100,
but I can't get that without using 2nd statement!
How does multiplying 256 to 2nd byte of received data solves problem?