Hello, trying to integrate a mux to my project to handle multiple analog inputs.
Having an issue where it seems that mux values dont seem to be different. I set bits to 0000 reading is say 500, change to 0001 reading is still 500 even though readings should be different.
I attached an image of how the NTE74HC4067 is wired. The analog inputs going into the mux and to A1 from the photo resistors are just there to show thats where my inputs are coming in at. In reality the two inputs going into the mux are from moisture sensors, the 3rd input going to A1 is a third moisture sensor not wired to the mux that that i can use it as a reference to see if the mux is working correctly, hopefully that makes sense.
int s0 = 0;
int s1 = 1;
int s2 = 2;
int s3 = 3;
void setup() {
Serial.begin(9600);
pinMode(s0,OUTPUT);
pinMode(s1,OUTPUT);
pinMode(s2,OUTPUT);
pinMode(s3,OUTPUT);
delay(1000);
}
void loop() {
digitalWrite(s0,LOW);
digitalWrite(s1,LOW);
digitalWrite(s2,LOW);
digitalWrite(s3,LOW);
delay(2000);
int sensorValue = analogRead(A0);
Serial.print(" right sensor 0000: ");
Serial.print( sensorValue);
digitalWrite(s0,HIGH);
digitalWrite(s1,LOW);
digitalWrite(s2,LOW);
digitalWrite(s3,LOW);
delay(2000);
sensorValue = analogRead(A0);
Serial.print(" left sensor 0001: ");
Serial.print(sensorValue);
sensorValue = analogRead(A1);
Serial.print(" non muxed: " );
Serial.println(sensorValue);
delay(2000);
Serial.println();
}
here is the data sheet i used:
heres my output:(note right sensor is in open air, left sensor and non muxed are in a cup of water)
right sensor 0000: 159 left sensor 0001: 143 non muxed: 223
right sensor 0000: 115 left sensor 0001: 128 non muxed: 266
right sensor 0000: 153 left sensor 0001: 113 non muxed: 302
right sensor 0000: 149 left sensor 0001: 120 non muxed: 322
heres my output:(all sensors in open air)
right sensor 0000: 739 left sensor 0001: 762 non muxed: 1020
right sensor 0000: 741 left sensor 0001: 732 non muxed: 1020
right sensor 0000: 745 left sensor 0001: 749 non muxed: 1020
