I believe the problem is that the calculation 1 << ana_0 is done using integer math because the 1 is an integer. The result is stored in an unsigned long, but only after it's overflowed. Try declaring the constant 1 as an unsigned long: 1UL