hi
ok guys this is really confusing.. I did this a couple of times, and it worked. But now I have wired a small test/debug-setup on the breadboard and somehow I can't get it working properly.
.. I have 8x button-switches connected to a 74HC4051..
.. and I have one button-switch, that is connected directly to aTeensy3.6... lets call it the "shiftButton"
void loop() {
pollShift(); // polls button9
pollCtrl(); // polls buttons 1-8
}
/* Polls Shift-Button and sets Status-Var */
void pollShift() {
if (btnShift.update()) {
if (btnShift.fallingEdge()) {
cfg.shiftStatus = true;
if(cfg.debug == true) {
Serial.println("Shift pressed..");
}
} else {
cfg.shiftStatus = false;
if(cfg.debug == true) {
Serial.println("Shift released..");
}
}
}
}
/* Polls all MUXES */
void pollCtrl() {
for (int i = 0; i <= 3; i++) {
digitalWrite(cfg.muxPinInh, HIGH);
cfg.MuxBit1 = bitRead(i, 0);
cfg.MuxBit2 = bitRead(i, 1);
cfg.MuxBit3 = bitRead(i, 2);
digitalWrite(cfg.muxPin1, cfg.MuxBit1);
digitalWrite(cfg.muxPin2, cfg.MuxBit2);
digitalWrite(cfg.muxPin3, cfg.MuxBit3);
digitalWrite(cfg.muxPinInh, LOW);
delayMicroseconds(40);
pollMuxDigital(i, "btnTrackSelect", cfg.btnTrackSelectPin);
}
}
/* Polls 4051 with digital Input-Sources */
void pollMuxDigital(int i, String elementName, int digitalPin) {
// btnTrackSelect
if(elementName == "btnTrackSelect") {
track[i].value_btnTrackSelect = digitalRead(digitalPin);
if (track[i].value_btnTrackSelect == HIGH && track[i].value_btnTrackSelectOld != track[i].value_btnTrackSelect) {
if(cfg.shiftStatus == true) {
if(debug == true) {
Serial.print("# trackSelect(): "); Serial.print(i); Serial.println();
}
} else {
if(debug == true) {
Serial.print("# MuteTrack(): "); Serial.print(i); Serial.println();
}
}
}
track[i].value_btnTrackSelectOld = track[i].value_btnTrackSelect;
}
now when I only do pollShift() in the loop(), I get the correct output in the serial-monitor. but when I add the pollCtrl(), somehow the 4051 gets triggered when the shiftButton is pressed(?) oO
also the 4051 spits out that a couple of pins went HIGH, when only one button is pressed.
I really don't know what else to try/check.. the IC is defitetly wired correctly