thanks for getting back to me with that code... in the time before i read that i had already written up some code and put it to work... i decided to not use the analog mux's yet... i've just got the inputs from the soil sensors going to individual analog inputs... i just was anxious to get it working... i figure i can get the multiplexers going once i've got enough sensors and solenoids to where i'll need them...
here is the code i wrote.
int dataPin = 8;
int latchPin = 9;
int clockPin = 10;
int plantOne = 800;
int plantTwo = 800;
int plantThree = 800;
void shiftControl(int SR4, int SR3, int SR2, int SR1, int duration)
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, SR4);
shiftOut(dataPin, clockPin, MSBFIRST, SR3);
shiftOut(dataPin, clockPin, MSBFIRST, SR2);
shiftOut(dataPin, clockPin, MSBFIRST, SR1);
digitalWrite(latchPin, HIGH);
delay(duration);
}
void waterControl(int solLVal, int solRVal, int pumpVal, int offset, int runTime)
{
shiftControl(solLVal, solRVal, 0, 0, offset);
shiftControl(pumpVal, solRVal, 0, 0, runTime);
shiftControl(solLVal, solRVal, 0, 0, offset);
}
void setup()
{
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
shiftControl(0,0,0,0,10);
Serial.begin(9600);
}
void loop()
{
shiftControl(0,0,0,1,10);
plantOne = analogRead(0);
Serial.print("Plant 1 : ");
Serial.print(plantOne);
Serial.print(" | ");
shiftControl(0,0,0,2,10);
plantTwo = analogRead(1);
Serial.print("Plant 2 : ");
Serial.print(plantTwo);
Serial.print(" | ");
shiftControl(0,0,0,4,10);
plantThree = analogRead(2);
Serial.print("Plant 3 : ");
Serial.println(plantThree);
Serial.print(" | ");
Serial.println(".............................................");
shiftControl(0,0,0,0, 1000);
if(plantOne < 375)
{
waterControl(0, 1, 128, 500, 2500);
Serial.println("Watering Plant 1...");
}
if(plantTwo < 375)
{
waterControl(0,2,128,500,2500);
Serial.println("Watering Plant 2...");
}
if(plantThree < 375)
{
waterControl(0,4,128,500,2500);
Serial.println("Watering Plant 3...");
}
}
let me know what you think, if there is any room for improvement or anything... thanks!