Hello everyone :),
I recently started with my journey into micorcontrollers and I wanted to create an automatic irrigation System with my Arduino Uno clone. The issue emerges from my multiplexer. It won't turn off, when I put the EN slot on HIGH. The simulation created the desired result but in reality my Multiplexer won't turn off at HIGH.
//Define Digital Channels as Mux switches
const int MuxS0 = 3;
const int MuxS1 = 4;
const int MuxS2 = 5;
const int MuxS3 = 6;
const int MuxSIG = A0;
const int MuxDisabler = 8;
//Define function to iterate easier through Mux Signals
int SetMuxChannel (byte channel)
{
digitalWrite(MuxS0, bitRead(channel, 0));
digitalWrite(MuxS1, bitRead(channel, 1));
digitalWrite(MuxS2, bitRead(channel, 2));
digitalWrite(MuxS3, bitRead(channel, 3));
}
void setup() {
pinMode(MuxS0, OUTPUT);
pinMode(MuxS1, OUTPUT);
pinMode(MuxS2, OUTPUT);
pinMode(MuxS3, OUTPUT);
pinMode(MuxDisabler, OUTPUT);
Serial.begin(9600);
delay(1000);
}
void loop()
{
//Disable the MUX to REALLY see that my values are zero.
//Thats the problem here. I'm getting semi random values but not zero :/
digitalWrite(MuxDisabler, HIGH);
for (int i = 0; i < 3; i++)
{
SetMuxChannel (i);
int HumiditySensorRead = analogRead(A0);
Serial.print("Sensor No = ");
Serial.print(i);
Serial.print(" = ");
Serial.println(HumiditySensorRead);
delay(500);
}
//Turn on the MUX to see the real values :)
digitalWrite(MuxDisabler, LOW);
for (int i = 0; i < 3; i++)
{
SetMuxChannel (i);
int HumiditySensorRead = analogRead(A0);
Serial.print("Sensor No = ");
Serial.print(i);
Serial.print(" = ");
Serial.println(HumiditySensorRead);
delay(500);
}
}
Here is the link to the simulation website: MuxTest
The Simulated Output is:
Sensor No = 1 = 0
Sensor No = 2 = 0
Sensor No = 0 = 0
Sensor No = 1 = 299
Sensor No = 2 = 349
Sensor No = 0 = 557
Sensor No = 1 = 0
Sensor No = 2 = 0
Sensor No = 0 = 0
Sensor No = 1 = 299
Sensor No = 2 = 349
Sensor No = 0 = 557
Sensor No = 1 = 0
Sensor No = 2 = 0
Sensor No = 0 = 0
Sensor No = 1 = 299
Sensor No = 2 = 349
Sensor No = 0 = 557
Sensor No = 1 = 0
Sensor No = 2 = 0
Sensor No = 0 = 0
Sensor No = 1 = 299
Sensor No = 2 = 349
Sensor No = 0 = 557
The real Output is:
Sensor No = 0 = 286
Sensor No = 1 = 74
Sensor No = 2 = 222
Sensor No = 3 = 3
Sensor No = 4 = 203
Sensor No = 0 = 296
Sensor No = 1 = 334
Sensor No = 2 = 292
Sensor No = 3 = 287
Sensor No = 4 = 291
Sensor No = 0 = 288
Sensor No = 1 = 26
Sensor No = 2 = 225
Sensor No = 3 = 91
Sensor No = 4 = 245
Sensor No = 0 = 296
Sensor No = 1 = 334
Sensor No = 2 = 293
Sensor No = 3 = 287
"I have more Soil moisture Sensors than the represented three potentiometers".
Is there something I didn't take into account like putting a certain resistor there?
Best wishes,
Ingo :).

