Hello friends,
I would like to ask you a question related to the de/multiplexer 74HC4051 and 74HC4067. My intention is to use a multiplexer to expand the number of analog inputs of Arduino. It seems easy, but I do not get it. In reality or simulating with Proteus software, the problem is always the same. I've tried my own codes and some codes that I found online.
The problem is that when I don’t have anything connected in the inputs of the 74HC4051 (from 0 to 7) or 74HC4067 (from 0 to 15), I have values different of 0. And when I connect for example 5V in one of the entries, the result is the same. I don't understand why...
I think that when nothing is connected to 4051 or 4067 the values in all the pins should be 0 and if there are some pin connected to 5V the value in this pin should be 1023.
You will see that in my code there is the "pinMode (muxSIG, INPUT_PULLUP);", if you remove it, the values still different of 0.
Any idea?
Thank you
const int muxSIG = A0;
const int muxSC = 9;
const int muxSB = 10;
const int muxSA = 11;
float muxValue = 0;
int SetMuxChannel(byte channel)
{
digitalWrite(muxSC, bitRead(channel, 0));
digitalWrite(muxSB, bitRead(channel, 1));
digitalWrite(muxSA, bitRead(channel, 2));
}
void setup()
{
Serial.begin(9600);
pinMode(muxSC, OUTPUT);
pinMode(muxSB, OUTPUT);
pinMode(muxSA, OUTPUT);
//pinMode(muxSIG, INPUT_PULLUP);
}
void loop()
{
for (byte i = 0; i <= 7; i++)
{
SetMuxChannel(i);
muxValue = analogRead(muxSIG);
Serial.print(muxValue);
Serial.print("\t");
Serial.print(" ,");
}
Serial.println();
delay(1000);
}




