Comparing 8 digital inputs to control multiplexer analog inputs

I think learning about arrays could make your task easier.
Certainly the code would be shorter.