Will my program work the way I want it to?

I am starting a project to code an automatic watering system without a pump, just a servo that will rotate to lower the tube, and water will flow down from it. Here is the code:

#include <Servo.h>
Servo myservo;
int moisture_sensor = 0;
int moisture_val;
void setup() {
// put your setup code here, to run once:

void loop() {
// put your main code here, to run repeatedly:
moisture_val = analogRead(moisture_sensor);
Serial.print("moisture level is ");
if (moisture_val < 600){


My only question is if the plant will overflow, since the servo just turns on. Will this be okay for an automatic watering system?

You have given no details of the watering system so it is hard to provide an answer. What, if anything, prevents the water flowing into the plant when the servo is at its high position ?

If moisture_val becomes equal to or greater than 600 the else will cause the servo to move to 0 degrees. Will that stop the flow?

Please read the "how to use the forum" stickies to see how to format and post code.

Just focusing on your title "Will my program work the way I want it to?" - the simple answer is try it and see what happens. The Arduino system is great for learning-by-doing.

After you have tried it you will also have a lot more useful information to give us if you still need help.