There is no problems with the sketch.
The reason for the post was to try and understand what is actually happening in this line.
The variable, i, just counts the bits as it moves along a bit map, prints out the bit state, and every 4 bits prints a 'space'.
After the 4th bit, i will =3, so (i+1) = 4. Applying the divisor, 8, cannot give me a remainder of 0, any more than if i=3 or i=7. It can only =0 when (i+1)=8 or 16, etc.
IamFof:
The variable, i, just counts the bits as it moves along a bit map, prints out the bit state, and every 4 bits prints a 'space'.
After the 4th bit, i will =3, so (i+1) = 4. Applying the divisor, 8, cannot give me a remainder of 0, any more than if i=3 or i=7. It can only =0 when (i+1)=8 or 16, etc.
You've supplied no code or proof that it behaves as you say. How do you expect to get any help?
IamFof:
There is no problems with the sketch.
The reason for the post was to try and understand what is actually happening in this line.
The variable, i, just counts the bits as it moves along a bit map, prints out the bit state, and every 4 bits prints a 'space'.
After the 4th bit, i will =3, so (i+1) = 4. Applying the divisor, 8, cannot give me a remainder of 0, any more than if i=3 or i=7. It can only =0 when (i+1)=8 or 16, etc.
Clearly there is something wrong with the code. We all agree the modulus operator is not returning what you expect. This indicates the value i is not what you expect. Add a simple print statement will prove this to be true or false. However, we can not assess what is wrong with that little snippit of code.
// print raw data
for ( uint8_t i = 0 ; i < 32 ; i++ ) {
Serial.print( bitRead( nsIrNec::dataRaw, i ) ) ;
if ( (i+1) % 8 == 0 ) Serial.print(' ' ) ;
}
Serial.println();
and is intended to print something like this, depending on the sample data:
00000000 11111111 11101010 00010101
nsIrNec::dataRaw is of type uint32_t
The '+1' is to ensure that the first space is after digit 7 (digits are numbered 0 to 7) is printed.
Without the '+1' the first space would appear after the first digit.