hy guys. Im doing watering system and I need some help with programing the damn thing. Problem is, Im using 3 moisture sensors and I cant program them the way i want to....Right now, pump starts if ALL 3 senzors are without watter, but i want it to turn on if either one is dry. Thank you. Here is my code:
int solenoidPin = 2;
const int dry = 630;
const int wet = 313;
void setup() {
Serial.begin(9600);
pinMode(solenoidPin, OUTPUT);
}
void loop() {
int sensorVal1 = analogRead(A0);
int sensorVal2= analogRead(A1);
int sensorVal3 = analogRead(A2);
int percentageHumididy1 = map(sensorVal1, wet, dry, 100, 0);
int percentageHumididy2 = map(sensorVal2, wet, dry, 100, 0);
int percentageHumididy3 = map(sensorVal3, wet, dry, 100, 0);
Serial.print(percentageHumididy1);
Serial.println("%");
Serial.print(percentageHumididy3);
Serial.println("%");
Serial.print(percentageHumididy2);
Serial.println("%");
delay(100);
if (sensorVal1 >= 500);
if (sensorVal2 >= 500)
if (sensorVal3 >= 500)
{
digitalWrite(solenoidPin, HIGH);
delay(1000);
}
else {
digitalWrite(solenoidPin, LOW);
}
}