Go Down

Topic: Sparkfun CD74HC4067 breakout not switching (Read 76 times) previous topic - next topic

bobbobkilu

I'm attempting to use the CD74HC4067 to recieve multiple analog inputs. I have it connected to the 5V power supply, with S0-S3 connected to digital pins 10-13, and SIG connected to A0.

Code: [Select]
int holes[12];

void setup() {
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  setMultiplexer(0x0);
  holes[0] = analogRead(A0);
  setMultiplexer(0x1);
  holes[1] = analogRead(A0);

  Serial.print("Hole 1 = ");
  Serial.println(holes[0]);
  Serial.print("Hole 2 = ");
  Serial.println(holes[1]);
  delay(500);

}

void setMultiplexer(byte address){
  digitalWrite(13,address & 1);
  digitalWrite(12,(address >> 1) & 1);
  digitalWrite(11,(address >> 2) & 1);
  digitalWrite(10,(address >> 3) & 1);
  }


when I run this with no input I get 1023 for both. If I add an input, to ANY of I/O the pins on the chip, BOTH read as something less than 1023.

What is going on here? Even if my little switching function there isnt working it should only be able to read from the first I/O pin right?

Paul__B

Shouldn't you set pins 10 to 13 as outputs with pinMode?

Go Up