So that code was working? Before I wired up the relay switches and pumps, values were going down when wet, and up when dry. reading about 750 when dry, 200 when wet. Then i wired up the relay and now it only reads 650 no matter what. Is it the code? i dont think so
// 4 control pins of the relay
int IN1 = 2;
int IN2 = 3;
int IN3 = 4;
int IN4 = 5;
// detect value from soil sensor
int Pin1 = A0;
int Pin2 = A1;
int Pin3 = A2;
int Pin4 = A3;
//
float sensor1Value = 0;
float sensor2Value = 0;
float sensor3Value = 0;
float sensor4Value = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(Pin1, INPUT);
pinMode(Pin2, INPUT);
pinMode(Pin3, INPUT);
pinMode(Pin4, INPUT);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, HIGH);
delay(500);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print("Asshole 1 - Moisture Level:");
sensor1Value = analogRead(Pin1);
Serial.println(sensor1Value);
if (sensor1Value > 450) {
digitalWrite(IN1, HIGH);
} else {}
digitalWrite(IN1, LOW);
delay (500);
Serial.print("Asshole 2 - Moisture Level:");
sensor2Value = analogRead(Pin2);
Serial.println(sensor2Value);
if (sensor2Value > 450) {
{
digitalWrite(IN2, HIGH);
}
} else {}
digitalWrite(IN2, LOW);
delay (500) ;
Serial.print("Asshole 3 - Moisture Level:");
sensor3Value = analogRead(Pin3);
Serial.println (sensor3Value);
if (sensor3Value > 450) {
{
digitalWrite(IN3, HIGH);
}
} else {}
digitalWrite(IN3, LOW);
delay (500);
Serial.print("Asshole 4 - Moisture Level:");
sensor4Value = analogRead(Pin4);
Serial.println(sensor4Value);
if (sensor4Value > 450) {
{
digitalWrite(IN4, HIGH);
}
} else {}
digitalWrite(IN4, LOW);
delay (500);
}