How many bits are we talking about here? First you refer to detecting the bits in a byte, then start talking about the 9th thru 12 bit. There are exactly 8 bits in a byte.

As for the problem, read the values into an array of bytes, AND the first byte with 0xff. If that turns out to be equal to 0xff, AND the next byte with 0x07. If that's equal to 0x07, you're done. The pattern you're looking for appears to be xxxxx111 11111111, and it sounds as if the manner of reading it (or at least the way you're testing it) is LSB first. If that's not the case, reverse the order of the tests.

By the way, bits and bytes are traditionally numbered 0 - n, with the least significant being 0. You'll save yourself a whole lot of confusion if you get into the habit of thinking of them that way, as most technical documentation uses this format.

Also,

this[

^] class comes in handy for these types of problems. Good luck! :-D

bit 14: can be 0 or 1

bit 15: can be 0 or 1