For the state machine? Well, quite simple, just set flag to indicate whether you're in manual or automatic mode and test for it. Something like this in loop():
if (c == 'L' || c == 'l' ) {
manual = true;
digitalWrite(waterPump2, HIGH);
}
else if (c == 'P' || c == 'p') {
manual = true;
digitalWrite(waterPump2, LOW);
}
else if (c == '1') {
manual = false)
}
if (manual == false) {
// do automatic stuff.
}