How shiftOut function works internally? (explanation on source code)
I'll assume bitOrder == LSBFIRST.


i is the bit number, i.e. the “index” of the next bit to write
1 is 00000001 in binary
&lt;&lt; is the shift left operator. It returns its first argument shifted left by as many positions as indicated by the second argument
1&lt;&lt;i is binary 00000001 shifted left by i positions, i.e. something like 0...010...0, where the single 1 is in the i-th position counting from the right (rightmost being position 0)
&amp; is the “bitwise and operator”, where any_bit &amp; 0 is zero and any_bit &amp; 1 is any_bit
val &amp; (1 &lt;&lt; i) is 0...0(i-th bit of val)0...0 in binary, where the i-th bit of val is in the i-th position of the result
!! is a double negation: it converts zero to zero and any non-zero value to one
!!(val &amp; (1 &lt;&lt; i)) is either 0 or 1, and is exactly the i-th bit of val