By the way your use of the logic operators is wrong.

For example you use:-

Let's look at exactly what this will do.

what you have here is in effect

register = register, logic operation, mask

Where in this case register is ADMUX, logic operator is the bitwise OR, and the mask is B00000010.

What the bitwise OR operation will do is to SELECTIVELY set bits to one while leaving other bits unchanged.

So if you do

ADMUX |= B00000010; // set channel 2

and some time later

ADMUX |= B00000100; // set channel 4

Then the value in ADMUX is Bxxxxx11x where the x is the logic level of the bits that were already in the register to begin with. So assuming the least significant bit was a 0 to begin with you will have changed the input channel to channel 6 not 4 like you might think.

So the rule for a bitwise OR is that:-

A one in the mask sets the corresponding bit to a one in the result ( register ).

A zero in the mask leaves the corresponding bit in the register unchanged.

So suppose you actually want to set just the channel it will involve selectively setting some bits to one and other bits to zero, which you can't do with just the bitwise OR.

To selectively set bits to zero you need to use the bitwise AND operation. The rule for using that is

A zero in the mask sets the corresponding bit a zero in the result ( register ).

A one in the mask leaves the corresponding bit in the register unchanged.

So in order to set a channel to a value you need an AND operation to clear out the three bits that define the channel and then you need an OR operation to set to one the bits in the channel number that are one.

So setting a channel requires two operations

ADMUX &= B1111000; // clear out the channel select bits

ADMUX |= B00000010; // set the channel select to what you want.

But suppose your channel number is in a variable? You can still use this method. This is an example of how a grown up would do it using hexadecimal to describe the numbers involved. Suppose the channel you want is in a variable called chn

ADMUX &= 0xF8; // clear out the channel select bits

ADMUX |= chn; // set the channel select to what is in the variable

That way you won't be back asking why the channel is not being set correctly.

If you know what all the bits in a register need to be set to just use the = operation by itself, no need to use any logic operators.