I am definitely missing informative comments in your code
From the code I can conclude these are pinnumbers.
const byte control0 = 5; //S3
const byte control1 = 4; //S2
const byte control2 = 3; //S1
const byte control3 = 2; //S0
I'm not sure If these are user definable of fixed for the shield. If these are fixed you might use #define
#define CONTROL_0 5
etc
on the other hard it screams for an array
byte controls[4] = { 5,4,3,2} ;
void setup()
{
for (byte i =0; i< 4; i++) pinMode(control[i], OUTPUT);
}
// avoid the repeating code
void muxSetPin(byte pin)
{
for (byte i =0; i< 4; i++) digitalWrite(control[i], bitRead(pin, 3-i); //something like that,
// NOTE reversing the pins in the control array could make it
// digitalWrite(control[i], bitRead(pin, i);
// a better name for control could be addresPin ??
}
void muxDigitalWrite(int pin, int value)
{
pinMode(14,OUTPUT);
muxSetPin(pin);
digitalWrite(14, value);
}
int muxDigitalRead(int pin)
{
pinMode(14, INPUT);
muxSetPin(pin);
return digitalRead(14);
}
int muxAnalogRead(int pin)
{
pinMode(A0, INPUT);
muxSetPin(pin);
return analogRead(A0);
}
and next step is putting it in some Class.
Furthermore I was wondering how to control 48 IO lines with just 4 address lines ?
my 2 cents,