Analog reading whit registers

Yes, THX @Grumpy_Mike for breaking this down.


Many times you will see that written like this

ADMUX &= ~B111; // clear out the channel select bits

which does the same and avoids a possible problem when variable lengths are different numbers of bits. No problem with either expression in this case.

And the belt and suspenders crowd might write the above as

ADMUX |= (chn &0x7);  // set the channel select

so chn can influence only the three bits it should. I guess the B&S ppl might even range check chn instead of crudely chopping it down to size…

a7