Using a geometric series to control many LEDs

(From a Direct Message)

The "(1 << i)" means 1 shifted left by 'i' bits. That gets you a 1, 2, 4, 8, 16, 32...

The "(value & (1 << i))" means, using the results of "(1 << i)" as a bit mask, return 0 if that bit of the value is 0 and non-zero if that bit of the value is a 1.

The "boolean ? true_value : false_value" is call a Ternary Operator. If the value to the left of the '?' is non-zero (true) use the true_value. If the value to the left of the '?' is 0 (false) use the false_value. In most cases this part is not really necessary: any 0 value is LOW and any non-0 value is HIGH, but there are a couple models where the names LOW and HIGH are special.

Very similar way: a list of pin numbers and a moving mask. Start with an integer containing zero. In a loop that goes through the pins from low bit to high bit, if the pin at that place in the array is reading LOW, add (or OR) the mask (1 << i) to the value. When the loop is done you have an integer.