Software challenge

What if there are two same value bits side-by-side? Or three bits?

But, you could sample for a while (using pulseIn) and take the lowest reading. Or, you may be able to collect a few samples and deduce the single bit time. I think the trick is to determine which timings are for odd numbers of bits or prime numbers of bits.

Good point that multible zero bits in a row is a possiblity, I'll have to think about that.