Hi!
Totally noob to Arduino but think I got the basics, so bare with me..
Long story short, I'm setting up a soilmoisture and automatic water system.
Got this code working out well. (post at the end)
Now I want to get going with the "if" and "else" commands.
if (sensorVal1 > 380 ){
digitalWrite(pump1, HIGH);
//I want this one to only stay HIGH for 10seconds, and then turn off and wait for another 15minutes to check the values again (and turn on again if the values are >380)
Should i read more about the "milli" coding?
All help appriciated ![]()
CODE:
#define soilSensor1 A0
#define soilSensor2 A1
#define pump1 2
#define pump2 3
const int dry = 523;
const int wet = 297;
void setup() {
pinMode(pump1, OUTPUT);
pinMode(pump2, OUTPUT);
Serial.begin(9600);
}
void loop() {
int sensorVal1 = analogRead(soilSensor1);
int percentageHumididy = map(sensorVal1, wet, dry, 100, 0)
;Serial.print(" Sensor 1 = ");
Serial.print(percentageHumididy);
Serial.println("%");
int sensorVal2 = analogRead(soilSensor2);
int percentageHumididy2 = map(sensorVal2, wet, dry, 100, 0)
;Serial.print(" Sensor 2 = ");
Serial.print(percentageHumididy2);
Serial.println("%");
if (sensorVal1 > 380 ){
digitalWrite(pump1, HIGH);
} else {
digitalWrite(pump1, LOW);
}
if (sensorVal2 > 450 ){
digitalWrite(pump2, HIGH);
} else {
digitalWrite(pump2, LOW);
}
delay(1000);
}
