Does this come close to what you want (compiles, not tested):
#include <Servo.h> //include servo library
#define MOISTURE_THRESH 450 //ADC counts base moisture level (you fill in correct value)
#define HYST 20 //ADC counts +/- from this value will switch
#define SAMPLE_INTERVAL 50 //mS mS between sensor checks
#define WET_POS 90 //
#define DRY_POS 0 //
Servo myservo; //define servo as servo
byte
waterSens[] = {A1, A3};
const byte
howManySensors = sizeof(waterSens) / sizeof(waterSens[0]);
int
grReadings[howManySensors];
void setup()
{
Serial.begin( 9600 );
Serial.println( "https://forum.arduino.cc/index.php?topic=641224" );
myservo.attach( 2 );//attach servo to pin 2
myservo.write( 0 );
Serial.print( "Number of sensors " ); Serial.println( howManySensors );
Serial.println( "setup() done" );
}//setup
void loop()
{
unsigned long
tNow;
static unsigned long
tSample = 0;
static byte
lastbWater = 0,
bWater = 0;
tNow = millis();
if( tNow - tSample >= SAMPLE_INTERVAL )
{
tSample = tNow;
for( int i=0; i<howManySensors; i++ )
{
int sensorValue = analogRead( waterSens[i] ); //read each twice twice due to channel change each pass
delayMicroseconds( 20 );
grReadings[i] = analogRead( waterSens[i] );
}//for
if( bWater == 0 )
{
for( int i=0; i<howManySensors; i++ )
bWater |= (grReadings[i] >= MOISTURE_THRESH+HYST) ? 1:0;
}//if
else
{
byte bDry = 0;
for( int i=0; i<howManySensors; i++ )
bDry |= (grReadings[i] > MOISTURE_THRESH-HYST) ? 1:0;
bWater = bDry;
}//else
if( bWater != lastbWater )
{
lastbWater = bWater;
myservo.write( (bWater) ? WET_POS : DRY_POS );
}//if
}//if
}//loop