cascade 16 74HC4067 multeplexers coding.

@aarg, it is odd :wink:

@cherifdekari
The evaluation of your logical AND is from left to right; HIGH will always evaluate to true on an Arduino so after that it will evaluate i & 0b1000000 which will return a number.

The better way

digitalWrite(M_S2, (i & 0b1000000) == 0b1000000);

(i & 0b1000000) == 0b1000000 will give you true or false and in Arduino land HIGH and true are both 1 and LOW and false are both 0 so it will work.

The purists probably want something like

digitalWrite(M_S2, (i & 0b1000000) == 0b1000000 ? HIGH : LOW);

This uses a ternary operator (obfuscated if/else) . If the condition evaluates to true, it returns HIGH as the second argument for the digitalWrite, if it evaluates to false it will return LOW as the second argument for the digitalWrite).