Switching Signal to Multiplexer not providing correct output via Code

Hi There Everyone,

I am trying to get mutiple inputs using Arduino Uno and Several 74HC4067 Chips. I'm using Four Digital Pins to Address each of the inputs on the Chip. However, the Switching seems to be not working according to plan. This is my Code...(When I measure the voltage across Digital Pin 1, I do not see it fluctuating, and only give 5V - note I have given adequate delay, 3sec to measure...)

Any help is much appreciated


int PinSelect0 =0;
int PinSelect1 =1;
int PinSelect2 =2;
int PinSelect3 =3;

int SensorValue;
int SensorValue1;

void setup()

{
pinMode(PinSelect0, OUTPUT);
pinMode(PinSelect1, OUTPUT);
pinMode(PinSelect2, OUTPUT);
pinMode(PinSelect3, OUTPUT);

pinMode(4, INPUT);
Serial.begin(9600);
}

void loop()

{
digitalWrite(PinSelect0, HIGH);
digitalWrite(PinSelect1, LOW);
digitalWrite(PinSelect2, LOW);
digitalWrite(PinSelect3, LOW);
SensorValue = digitalRead(4); // read the arduino input pin the Chip is using
Serial.print(SensorValue); //use the result
delay(3000);
digitalWrite(PinSelect0, HIGH);
digitalWrite(PinSelect1, HIGH);
digitalWrite(PinSelect2, LOW);
digitalWrite(PinSelect3, LOW);
SensorValue1 = digitalRead(4); // read the arduino input pin the Chip is using
Serial.print(SensorValue1); //use the result
delay(3000);
// break;

 SensorValue = digitalRead(4); // read the arduino input pin the Chip is using
        Serial.print(SensorValue); //use the result

Are you saying you're expecting something other than 1 or 0?

No, I expect 1 or 0 only...the Print is just for observation

When I measure the voltage across Digital Pin 1, I do not see it fluctuating, and only give 5V

Why are you expecting digital pin 1 to change?

The 74HC4067; 74HCT4067 is a 16-channel analog multiplexer/demultiplexer with four
address inputs (S0 to S3), an active-LOW enable input (E), sixteen independent
inputs/outputs (Y0 to Y15) and a common input/output (Z).

How do you have the chip(s) connected to the Arduino?

I am expecting Digital Pin2 to change as I have two set of selection statements in my code. Within the loop the first addressing is to select Output 1 of the IC - Y1(Address 0001), and next is to read output 3 of the IC - Y3 (address 0011 in Binary addressing) so Digital Pin 1 (2nd Lowermost Bit) should change between 0 to 1 within the loop. (I have added a delay to ensure that the state does not change too fast to measure) - So ideally the voltage should change between 5V and something much less to logic 0.

I have the Chips connected, but even without connecting them, I do not see the variance when I measure DigitalPin2 Voltage from Arduino..

Thank you very much for your assitance in advance :slight_smile:

I am expecting Digital Pin2 to change as I have two set of selection statements in my code.

So what have you connected on the input side of the multiplexer?

I do not see the variance when I measure DigitalPin2 Voltage from Arduino.

That code does not set pin 2 to anything other than a logic zero.

It is not a good idea to use pins 0 or 1 as they are used for serial communication.

Thanks I will re do without using Pin0 & 1. But I did try similarly to use the Analog Pins 0 -3 to address mux inputs, with same results...anyway My MUX is connected to 16 PhotoTransistors - but in this test case I just plug the test inputs to +5V (Vcc)

But I did try similarly to use the Analog Pins 0 -3 to address mux inputs, with same results.

Analog pins are input only. No wonder you can't send data to the chip...

Ohh..I'll redo it Thanks for clearing that out...!

Analog pins are input only

Yes but if you call them pin 14 for analogue 0, pin 15 for analogue 1 ... and so on they can be used as digital outputs.

But I did try similarly to use the Analog Pins 0 -3 to address mux inputs, with same results

Because as I said

That code does not set pin 2 to anything other than a logic zero.

You may want to first experiment with the multiplex chip independent of the arduino. Use a multimeter across the input/common output of the chip, power the chip with 5v, and experiment with the control pins either connected to 5v or ground. If the control pins float when not set to 5v, you may not get what you expect.

Hi Everyone. Thank You for the Valuable Information ( Grumpy_Mike, zoomkat, PaulS). I have re-done the wiring using pins 2-5 for Switching and 6-9 for Data Input from Multiplexer Chips. It works fine now.