#define DATA_PIN 11
#define LATCH_PIN 12
#define CLOCK_PIN 13
#define fmuxd0 6
#define fmuxd1 7
#define fmuxd2 8
#define fmuxOut 9
#define smuxd0 3
#define smuxd1 5
#define smuxd2 4
#define smuxOut 10
#define NUM_SHIFT_REGS 6
const uint8_t numOfRegisterPins = NUM_SHIFT_REGS * 8;
int data[48] = {1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1};
void setup() {
Serial.begin(115200);
pinMode(fmuxd0, OUTPUT);
pinMode(fmuxd1, OUTPUT);
pinMode(fmuxd2, OUTPUT);
pinMode(smuxd0, OUTPUT);
pinMode(smuxd1, OUTPUT);
pinMode(smuxd2, OUTPUT);
pinMode(fmuxOut, INPUT);
pinMode(smuxOut, INPUT);
pinMode(DATA_PIN, OUTPUT);
pinMode(CLOCK_PIN, OUTPUT);
pinMode(LATCH_PIN, OUTPUT);
digitalWrite(LATCH_PIN, LOW);
for (int i = numOfRegisterPins - 1; i >= 0; i--) {
digitalWrite(CLOCK_PIN, LOW);
digitalWrite(DATA_PIN, data[i]);
digitalWrite(CLOCK_PIN, HIGH);
}
digitalWrite(LATCH_PIN, HIGH);
}
void loop() {
Serial.println("select d1 d0 out out2");
for(int inx=0;inx<2;inx++){
for(int index=0;index<4;index++){
if (inx == 0){
digitalWrite(fmuxd0, LOW);
digitalWrite(smuxd0, LOW);
Serial.print(" ");
Serial.print("0");
} else {
digitalWrite(fmuxd0, HIGH);
digitalWrite(smuxd0, HIGH);
Serial.print(" ");
Serial.print("1");
}
Serial.print(" ");
if (index > 1) {
digitalWrite(fmuxd1, HIGH);
digitalWrite(smuxd1, HIGH);
Serial.print("1");
} else {
digitalWrite(fmuxd1, LOW);
digitalWrite(smuxd1, LOW);
Serial.print("0");
}
Serial.print(" ");
if ((index+1) % 2) {
digitalWrite(fmuxd2, LOW);
digitalWrite(smuxd2, LOW);
Serial.print("0");
} else {
digitalWrite(fmuxd2, HIGH);
digitalWrite(smuxd2, HIGH);
Serial.print("1");
}
Serial.print(" ");
if (digitalRead(fmuxOut) == HIGH){
Serial.print("1");
} else {
Serial.print("0");
}
Serial.print(" ");
if (digitalRead(smuxOut) == HIGH){
Serial.println("1");
} else {
Serial.println("0");
}
delay(1000);
}
}
}