I am currently writing a program that reads an output voltage from a capacitive moisture sensor and depending on the moisture content, it will water some plants accordingly. I would like to make it so that a user can change the condition in real time because different plants will require different amounts of water. This will give a little more freedom on how much water the user would prefer for their plant. This is the code I have so far:
int solenoidPin = 4; //connected to Digital 4
int moisturePin = A0; //connected to Analog A0
void setup() {
Serial.begin(9600);
pinMode(solenoidPin, OUTPUT);
}
void loop() {
int val;
moisture = analogRead(moisturePin); //connect sensor to Analog A0
Serial.println(val); //print the value to serial port
delay(1000); //wait 1 second for next reading
if (moisture <= 350) //if moisture is less than reading 350 {
digitalWrite(solenoidPin, HIGH); //switch solenoid ON
delay(600000) //water for ten minutes
digitalWrite(solenoidPin, LOW); //switch solenoid OFF
}
else {
digitalWrite(solenoidPin, LOW); //switch solenoid OFF
}
}
I am aware that there is a touch screen shield for the Arduino and I could possibly allow the user to interact what is going on. However, I'm just asking if it's possible to change the if (moisture <= 350)
while the code is running and perhaps allowing the user to change that value. If so, then how? Could I use a touch screen shield or another shield that allows a user to change the condition?