Sending side:# data10bits is at least 16 bits wide.byte1 = (data10bits >> 8) & 0x03;byte2 = (data10bits & 0xff);rfSend(byte1, BYTE);rfSend(byte2, BYTE);Receiving side:# Again, data10bits is at least 16 bits.byte1 = rfRecv(); # get a single bytebyte2 = rfRecv(); # get second bytedata10bits = (byte1 << 8) | byte2;
>>, << bit-shift operators. Consider a number represented in binary as a 10001000. Applying >> 1 results in 01000100. Applying <<2 to that result will itself result in 00010000 - the shifted-off bits are not saved, and the 'new' bits are initialised to zero.& - bitwise AND. The result of 0110 & 0010 is 0010 - only those bits that are set in both inputs result in an output 1 in that position.| - bitwise OR. The result of 0110 | 1010 is 1110 - anywhere a 1 appears in any of the inputs, a 1 will be output in that position.