Help with Syntax of While Loop

I’m trying to get a library converted to run on an Argon and I’m working through the compile errors.

I get this error which makes sense but I am not sure if I’m understanding what their goal was with this or not.

It looks like the while loop is just waiting until the Wire.read() does not return the byte status 10000000.

To me the

while (!(Wire.read() & B10000000));

Should be

while (!(Wire.read() == B10000000));

But I’m not sure if I’m missing something simple here.

To create binary literals use 0b, not B.

This should be 0b10000000

Otherwise the original logic looks correct.

It's actually waiting until the bit is set, using bitwise AND (&).

Man I was pretty far off :grinning:

Thanks for the quick solution!

Glad I didn't assume I knew the fix and asked :grinning:

1 Like

Fun fact:

The B… notation is something very Arduino specific and when including Arduino.h you will get it back too.
However, the way it is implemented makes me cringe :stuck_out_tongue_closed_eyes:

3 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.