Hello,
I have an Arduino Uno R3 and a Sparkfun 16-channel multiplexer (CD74HC4067). I have a lot of potentiometers that I want to read values from at once, and the Uno and even the Arduino Mega don't have enough analog inputs. The multiplexer seems like it should be pretty simple to operate, just give it Vcc, ground, and a 4-bit channel selection to choose which of the 16 channels you want to access through the signal pin.
The problem is that when I hook everything up and try to access a channel, I can only seem to get gibberish out of the signal pin, even when I'm only trying to access one channel (in this case called elbow). I have mine hooked up just like this diagram from a tutorial I found (with the signal pin connected to A0, and the channel selection connected to pins 2-5):
And here is the code that I'm using:
void setup(){
Serial.begin(9600);
pinMode(A0, INPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
}
void loop(){
digitalWrite(2, HIGH); // pins 2-5 used to select channel "0011"
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW); // ties the enable pin low (active low)
int elbow = analogRead(A0);
Serial.print("elbow:");
Serial.println(elbow);
I've also attempted to use the stechio Arduino multiplexer library, which simplifies the coding, but that doesn't seem to work either.
One thing that I tried was to just send the multiplexer the channel selection (0011) with NO potentiometers or other analog sources hooked up anywhere. Then I used a multimeter continuity test to see if Channel 3 and Signal were electrically connected, but they weren't, instead I would get a weird fluctuating resistance between the two.
I have a second multiplexer which seems to be exhibiting the same issue. Is there anything I'm missing here?