The 3013
was only a typo - the HEX I had given with it was indeed the one for 3031
. I have edited this already.
No you don't change the 1
, you provide the desired bit number in the designated variable bitNumber
.
If bitNumber == 3
the 1
(0b00000001) gets shifted three places to the left (0b00001000) so you'll test bit 3.
Similarly for the 32bit question you are shifting the bits to the left to bring them in position.
registerValue = Wire.read();
registerValue |= (Wire.read() << 8);
registerValue |= (Wire.read() << 16);
registerValue |= (Wire.read() << 24);
As stated in short in an earlier post
In binary this would look like this, if your read byte is always 0b0111 for example:
1. 0b00000000 00000000 00000000 00000111 // shift << 0
2. 0b00000000 00000000 00000111 00000000 // shift << 8
3. 0b00000000 00000111 00000000 00000000 // shift << 16
4. 0b00000111 00000000 00000000 00000000 // shift << 24
or ------------------------------------------------ // logical OR with | symbol
0b00000111 00000111 00000111 00000111
BTW: I don't think it's good practice just to ignore the error bits. You may run into troubles later on when the indicated error starts to impair your following readings.
And I already had answered your question
Please! Read the posts!