Hi guys,
So i'm running this code through a 4067 mux with 8 buttons for testing. The issue is, when testing each button from 1 - 7, the led comes on but at very low brightness. The eighth button displays the LED at full brightness. I've tested the connections on another sketch without using a mux array and address individually and it works, so the physical connections seem correct which leads me to believe its the code. Any ideas?
Appreciate the help
So i'm running this code through a 4067 mux with 8 buttons for testing. The issue is, when testing each button from 1 - 7, the led comes on but at very low brightness. The eighth button displays the LED at full brightness. I've tested the connections on another sketch without using a mux array and address individually and it works, so the physical connections seem correct which leads me to believe its the code. Any ideas?
Code:
int ledPin = 13;
int muxAddressPins [4] = {2, 3, 4, 5};
int muxPin = 6;
int muxChannel[8][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
};
void setup() {
Serial.begin(9600);
for (int i = 0; i < 4; i++) {
pinMode(muxAddressPins[i], OUTPUT);
}
pinMode(muxPin, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
}
void loop() {
for (int j = 0; j < 8; j++) {
for (int i = 0; i < 4; i++) {
digitalWrite(muxAddressPins[i], muxChannel[j][i]);
ledActive();
}
}
delay(10);
}
void ledActive() {
if (digitalRead(muxPin) == LOW) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}
Appreciate the help