Newbie here. I'm setting up an irrigation system using Arduino Uno, relays and three solenoids. I live out in the country and my water pressure is minimal and so I cannot irrigate all three zones at once. When solenoid A is open I need B and C to be closed. Once A is satisfied, then move on to B and close A and C.
Etc. It is probably simple enough but for a retired person with no electronic background, I cannot get my head around it.
I hope I have given you enough information. If not please do not hesitate to ask for more. The code follows.
I thank you in advance.
Pax2
const int sensorValueA = A0;
const int sensorValueB = A1;
const int sensorValueC = A2;
const int solenoidA = 13;
const int solenoidB = 12;
const int solenoidC = 11;
void setup() {
Serial.begin(9600);
// read the input on 3 analog pins:
//analogRead(sensorValueA); Serial.println(sensorValueA);
//analogRead(sensorValueB); Serial.println(sensorValueB);
//analogRead(sensorValueC); Serial.println(sensorValueC);
pinMode(solenoidA, OUTPUT);
pinMode(solenoidB, OUTPUT);
pinMode(solenoidC, OUTPUT);
}
void loop() {
int outputValueA;
int humidityRealA;
int outputValueB;
int humidityRealB;
int outputValueC;
int humidityRealC;
outputValueA= analogRead(sensorValueA);
humidityRealA = map(outputValueA, 1023, 200, 0, 100);
outputValueB= analogRead(sensorValueB);
humidityRealB = map(outputValueB, 1023, 250, 0, 100);
outputValueC= analogRead(sensorValueC);
humidityRealC = map(outputValueC, 1023, 270, 0, 100);
Serial.print ("Sorsor A ");
Serial.print(humidityRealA);
Serial.println ("%");
delay (500);
Serial.print ("Sorsor B ");
Serial.print(humidityRealB);
Serial.println ("%");
delay (500);
Serial.print ("Sorsor C ");
Serial.print(humidityRealC);
Serial.println ("%");
delay(500);
digitalWrite(solenoidA, LOW);
digitalWrite(solenoidB, LOW);
digitalWrite(solenoidC, LOW);
if (humidityRealA < 60)
{
digitalWrite(solenoidA, HIGH);
}
else if (humidityRealA > 85){
digitalWrite(solenoidA, LOW); }
if (humidityRealB < 60)
{
digitalWrite(solenoidB, HIGH);
}
else if (humidityRealB > 85){
digitalWrite(solenoidB, LOW); }
if (humidityRealC < 60)
{
digitalWrite(solenoidC, HIGH);
}
else if (humidityRealC > 85){
digitalWrite(solenoidC, LOW); }}
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.