Reconfigure PinMode and Understanding what it is doing

I have three resistive sensors that have some unique demands. They are part of a voltage divider (I will include a schematic) I have the hardware to make it happen but I am not sure what the code should be.

These are the needs and how I am trying to meet them. The actual question will be in bold

  1. The sensor must be isolated from ground and power between readings.
    -I am using a 74HC4052 multiplexer to solve this (its working as expected)

  2. The sensor should be read 70ms after being powered
    -easy enough just get the timing right in the code with the multiplexer

  3. While not being read the analog input should be reconfigured to a low digital output to discharge the sensor.
    -Here is where the real question begins
    -Here is how I imagine this timing working

1-start up arduino and set the A1-A3 to low outputs
2-just before being read reconfigure a1-a3 outputs to inputs by pinMode(A1,INPUT) ...;
3-Power the device through multiplexer (This is controlled through pins 2,3,13 and the multiplexer. You can see this in my code)
4- take the analog reading using int A_WMK_1 = analogRead(A1);
5-Terminate power to the sensor through the multiplexer
6-reconfigure a1-a3 to outputs and set them low.
Repeat steps 2-6

Am I understanding and using pinMode correctly? During the read I do not want A1-A3 to sink or source anything. Will setting them to inputs do that for me?

Here is my code

void setup() {
  Serial.begin(19200);
  Serial.println("Serial Begun");
  pinMode(2,OUTPUT);
  pinMode(3,OUTPUT);
  pinMode(13,OUTPUT);
  pinMode(A1,OUTPUT);
  pinMode(A2,OUTPUT);
  pinMode(A3,OUTPUT);
  digitalWrite(A1,LOW);
  digitalWrite(A2,LOW);
  digitalWrite(A3,LOW);
  
}

void ReadWatermark(){
      //Read Watermark 1
Serial.println("Reading WMK1");
      pinMode(A1,INPUT);
      digitalWrite(2,LOW); //These digital Writes configure the multiplexer to charge the sensor
      digitalWrite(3,LOW);
      digitalWrite(13,LOW);
      delay(70);
   
      int A_WMK_1 = analogRead(A1);
      digitalWrite(13,HIGH); //Terminates power to the sensor given through multiplexer
      pinMode(A1,OUTPUT);
      digitalWrite(A1,LOW);
      
      //Read Watermark 2
Serial.println("Reading WMK2");
      pinMode(A3,INPUT);
      digitalWrite(2,HIGH); //These digital Writes configure the multiplexer to charge the sensor
      digitalWrite(3,LOW);
      digitalWrite(13,LOW);
      delay(70);
      int A_WMK_2 = analogRead(A2);
      digitalWrite(13,HIGH); //Terminates power to the sensor given through multiplexer
      pinMode(A1,OUTPUT);
      digitalWrite(A1,LOW);
      
      //Read Watermark 3
Serial.println("Reading WMK3");
      pinMode(A3,INPUT);
      digitalWrite(2,LOW); //Configure the multiplexer to charge the sensor
      digitalWrite(3,HIGH);
      digitalWrite(13,LOW);
      delay(70);
      int A_WMK_3 = analogRead(A3);
      digitalWrite(13,HIGH); //Terminates power to the sensor given through multiplexer
      pinMode(A1,OUTPUT);
      digitalWrite(A1,LOW);  
}
void loop() {
ReadWatermark();
delay(4000);  

}

Attached is the schematic if you wanted to know what was up.

Looks fine to me. And even so, the analogRead will set up the pin as analogInput without pull up, it does not need the pinMode. But in this case you do because you want to float it before you turn on the sensor you need it.

Btw, what sensor is it (name/type)? Because it looks a bit odd you need to float both + and - of the sensor but pull the reading low to discharge. If the sensor has indeed only two leads as your drawing suggests that's useless. There is no path to indeed discharge the capacitor. The other end of the cap needs to be connected to GND as well to get actually discharged (and I think that is the WMK- connection that it is connected to).

Ow, btw, I stopped reading the code after the first couple of lines. I think code where you don't give your pins a proper name but keep on using analogRead(A1) etc in your code very useless. It's prone to errors because you a) The code itself does not explain what is does and b) it's easy to mix up pins in the process. Just start you're sketch with a simple pin definition list

const byte SensorPins[] = {A1, A2, A3};
const byte MuxPins[] = {2, 3};
const byte MuxE = 13;
//etc

Easier to change as well.