[SOLVED] - CD74HC4067 Multiplexer won't disable at HIGH

Hello everyone :),

I recently started with my journey into micorcontrollers and I wanted to create an automatic irrigation System with my Arduino Uno clone. The issue emerges from my multiplexer. It won't turn off, when I put the EN slot on HIGH. The simulation created the desired result but in reality my Multiplexer won't turn off at HIGH.

//Define Digital Channels as Mux switches
const int MuxS0 = 3;
const int MuxS1 = 4;
const int MuxS2 = 5;
const int MuxS3 = 6;
const int MuxSIG = A0;
const int MuxDisabler = 8;

//Define function to iterate easier through Mux Signals
int SetMuxChannel (byte channel)
{
  digitalWrite(MuxS0, bitRead(channel, 0));
  digitalWrite(MuxS1, bitRead(channel, 1));
  digitalWrite(MuxS2, bitRead(channel, 2));
  digitalWrite(MuxS3, bitRead(channel, 3));
}

void setup() {
  pinMode(MuxS0, OUTPUT);
  pinMode(MuxS1, OUTPUT);
  pinMode(MuxS2, OUTPUT);
  pinMode(MuxS3, OUTPUT);
  pinMode(MuxDisabler, OUTPUT);
  Serial.begin(9600);
  delay(1000);
}

void loop() 
{
  //Disable the MUX to REALLY see that my values are zero.
  //Thats the problem here. I'm getting semi random values but not zero :/
  digitalWrite(MuxDisabler, HIGH);
  for (int i = 0; i < 3; i++)
  {
    SetMuxChannel (i);
    int HumiditySensorRead = analogRead(A0);
    Serial.print("Sensor No = ");
    Serial.print(i);
    Serial.print(" = ");
    Serial.println(HumiditySensorRead);
    delay(500);
  }

  //Turn on the MUX to see the real values :)
  digitalWrite(MuxDisabler, LOW);
  for (int i = 0; i < 3; i++)
  {
    SetMuxChannel (i);
    int HumiditySensorRead = analogRead(A0);
    Serial.print("Sensor No = ");
    Serial.print(i);
    Serial.print(" = ");
    Serial.println(HumiditySensorRead);
    delay(500);
  }
}

Here is the link to the simulation website: MuxTest

The Simulated Output is:

Sensor No = 1 = 0
Sensor No = 2 = 0
Sensor No = 0 = 0
Sensor No = 1 = 299
Sensor No = 2 = 349
Sensor No = 0 = 557
Sensor No = 1 = 0
Sensor No = 2 = 0
Sensor No = 0 = 0
Sensor No = 1 = 299
Sensor No = 2 = 349
Sensor No = 0 = 557
Sensor No = 1 = 0
Sensor No = 2 = 0
Sensor No = 0 = 0
Sensor No = 1 = 299
Sensor No = 2 = 349
Sensor No = 0 = 557
Sensor No = 1 = 0
Sensor No = 2 = 0
Sensor No = 0 = 0
Sensor No = 1 = 299
Sensor No = 2 = 349
Sensor No = 0 = 557

The real Output is:

Sensor No = 0 = 286
Sensor No = 1 = 74
Sensor No = 2 = 222
Sensor No = 3 = 3
Sensor No = 4 = 203
Sensor No = 0 = 296
Sensor No = 1 = 334
Sensor No = 2 = 292
Sensor No = 3 = 287
Sensor No = 4 = 291
Sensor No = 0 = 288
Sensor No = 1 = 26
Sensor No = 2 = 225
Sensor No = 3 = 91
Sensor No = 4 = 245
Sensor No = 0 = 296
Sensor No = 1 = 334
Sensor No = 2 = 293
Sensor No = 3 = 287

"I have more Soil moisture Sensors than the represented three potentiometers".

Is there something I didn't take into account like putting a certain resistor there?

Best wishes,
Ingo :).


  digitalWrite(MuxDisabler, HIGH);
  for (int i = 0; i < 3; i++)
  {
    SetMuxChannel (i);
    int HumiditySensorRead = analogRead(A0);
    Serial.print("Sensor No = ");
    Serial.print(i);
    Serial.print(" = ");
    Serial.println(HumiditySensorRead);
    delay(500);
  }

  • Setting E to HIGH prevents you from reading the output on the mux output pin.
    What do you want to happen here ? :thinking:

Hello Larry :),

this section is there for debuging purposes. I should get 0 for every read this way, but I get some random values if I full the EN pin of my Multiplexer on HIGH :/.

Best wishes.

  • Add a load resistance to the A0 input to discharge the pin.

  • Also:

1 Like

Regarding 1)
That actually worked :).

  • With 220 Ohm the Values decreased a bit and the output during EN on HIGH decreased significantly to 2 rel units instead of 400 or 1000.
  • With 10K Ohms the Values stayed pretty much unchanged and during EN in HIGH the values decreased to 3 to 4 rel. units.

Regarding 2)
Yeah I messed that one up during generating the simulation. It somehow worked that way anyways.

Thank you so much for the tip with the discharging resistance :D.

In Germany we say "Ehrenmann" [youth slang] to someone who helps others. That means "man of honor" :).

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.