propa
Well-known member
Hi,
Found this wonderful tutorial https://youtu.be/OgaeEiHemU4 and adapted some code.
that should work right?
I've added the 50micro secs delay, but haven't got anything registering on serial monitor yet. I've only got two buttons hooked to 7hct4051 that shouldn't make a difference right? Powering the 74HCT4051 with 5v as well.
Here's the schematic:
Found this wonderful tutorial https://youtu.be/OgaeEiHemU4 and adapted some code.
Code:
int pin_Out_S0 = 1;
int pin_Out_S1 = 2;
int pin_Out_S2 = 3;
int pin_In_Mux1 = 4;
int pin_In_Mux2 = 5;
int Mux1_State[8] = {0};
int Mux2_State[8] = {0};
int led = 6;
void setup() {
pinMode(pin_Out_S0, OUTPUT);
pinMode(pin_Out_S1, OUTPUT);
pinMode(pin_Out_S2, OUTPUT);
pinMode(led, OUTPUT);
pinMode(pin_In_Mux1, INPUT);
//pinMode(pin_In_Mux2, INPUT);
Serial.begin(9600);
delay(20);
}
void loop() {
updateMux();
for(int i = 0; i < 8; i ++) {
if(i == 7) {
Serial.println(Mux1_State[i]);
} else {
Serial.print(Mux1_State[i]);
Serial.print(",");
}
}
}
void updateMux () {
for (int i = 0; i < 8; i++){
digitalWrite(pin_Out_S0, HIGH && (i & B00000001));
digitalWrite(pin_Out_S1, HIGH && (i & B00000010));
digitalWrite(pin_Out_S2, HIGH && (i & B00000100));
Mux1_State[i] = digitalRead(pin_In_Mux1);
//Mux2_State[i] = digitalRead(pin_In_Mux2);
delayMicroseconds(50);
}
}
that should work right?
I've added the 50micro secs delay, but haven't got anything registering on serial monitor yet. I've only got two buttons hooked to 7hct4051 that shouldn't make a difference right? Powering the 74HCT4051 with 5v as well.
Here's the schematic: