int s0 = 18;
int s1 = 5;
int s2 = 4;
int s3 = 2;
int SIG1 = 13;
int x0 = 23;
int x1 = 22;
int x2 = 21;
int x3 = 19;
int SIG2 = 12;
void setup(){
pinMode(18, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
pinMode(2, OUTPUT);
pinMode(13, OUTPUT);
pinMode(23, OUTPUT);
pinMode(22, OUTPUT);
pinMode(21, OUTPUT);
pinMode(19, OUTPUT);
}
void loop(){
int controlPin1[] = {s0, s1, s2, s3};
int controlPin2[] = {x0, x1, x2, x3};
int muxChannel[16][4]={
{0,0,0,0}, //channel 0
{1,0,0,0}, //channel 1
{0,1,0,0}, //channel 2
{1,1,0,0}, //channel 3
{0,0,1,0}, //channel 4
{1,0,1,0}, //channel 5
{0,1,1,0}, //channel 6
{1,1,1,0}, //channel 7
{0,0,0,1}, //channel 8
{1,0,0,1}, //channel 9
{0,1,0,1}, //channel 10
{1,1,0,1}, //channel 11
{0,0,1,1}, //channel 12
{1,0,1,1}, //channel 13
{0,1,1,1}, //channel 14
{1,1,1,1} //channel 15
};
for(int j = 0; j < 16; j ++){
for(int i = 0; i < 4; i ++){
digitalWrite(controlPin1[i], muxChannel[j][i]);
}
analogWrite(SIG1,HIGH);
}
}