Flood / Drain Table control

Hi,
I am looking to control 3 solenoid valves + sequence (fill hydroponic table and drain it) based on a RTC set for 3 different times. The timer works, and when the "if" code runs it will run the lcd code but will not run the pins for the valves.
Looking to get the first sequence to fill to a distance value and then back to normal running for a delay before the draining sequence.
For the draining DP+Valve sequence happen when the distance is < a value.
I don't have a lot of coding experience. I had this working in the proper sequence but using timers / delays, however this posed a risk of overfilling the table if the times were off.
Using Arduino Mega 2560 but have, uno, esp8266, and pico if they are better suited.
If this is even possible looking for some direction / guidance on correct way to complete this project.

Thanks

//ultrasonic

#include "NewPing.h"
 
#define TRIGGER_PIN  3
#define ECHO_PIN     4
#define MAX_DISTANCE 400
 
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
 
float duration, distance;
 
int iterations = 5;

//LCD

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

//RTC

//clock / timer
#include <DS3231.h>
DS3231 rtc(SDA, SCL);
Time t;

//Valves

int SV1 = 5;   //Valve 1 Miniflow
int SV2 = 6;   //Valve 2 Discharge to Table
int SV3 = 7;   //Valve 3 Return + Diaphragm pump

//Times

//Time 1
const int OnHour = 1; //SET TIME TO ON RELAY (24 HOUR FORMAT)
const int OnMin =  47;
const int OffHour = 6; //SET TIME TO OFF RELAY
const int OffMin =  45;

//Time 2
const int OnHour2 = 0; //SET TIME TO ON RELAY (24 HOUR FORMAT)
const int OnMin2 =  51;
const int OffHour2 = 14; //SET TIME TO OFF RELAY
const int OffMin2 =  45;

//Time 3
const int OnHour3 = 22; //SET TIME TO ON RELAY (24 HOUR FORMAT)
const int OnMin3 =  00;
const int OffHour3 = 22; //SET TIME TO OFF RELAY
const int OffMin3 =  45;


 
void setup() {
  lcd.begin();
  lcd.backlight();
  Serial.begin (9600);
  rtc.begin();

     //Valves 
 pinMode(SV1, OUTPUT);
 pinMode(SV2, OUTPUT);
 pinMode(SV3, OUTPUT);

}
 
void loop() {
  digitalWrite(SV1, "LOW");
  digitalWrite(SV2, "LOW");
  digitalWrite(SV3, "LOW");
  
  // gets time
  t = rtc.getTime();
  Serial.print(t.hour);
  Serial.print(" hour(s), ");
  lcd.print("TIME: H ");
  lcd.print(t.hour);
  Serial.print(t.min);
  Serial.print(" minute(s)");
   lcd.print(" M ");
   lcd.print(t.min);
  Serial.println(" ");
   delay (5000);
   lcd.clear();

   
  duration = sonar.ping_median(iterations);
  
  // Determine distance from duration
  // Use 343 metres per second as speed of sound
  
  distance = (duration / 2) * 0.0343;
  
  // Send results to Serial Monitor
  Serial.print("Distance = ");
  lcd.print("Distance = ");
  if (distance >= 400) {
    Serial.print("Out of range");
  }
  else {
    Serial.print(distance);
    lcd.print(distance);
    Serial.print("cm");
    delay(5000);
    lcd.clear();
    Serial.println();
    delay(500);
  

  if  ((t.hour == OnHour && t.min == OnMin)||(t.hour == OnHour2 && t.min == OnMin2)||(t.hour == OnHour3 && t.min == OnMin3)){
  lcd.clear();
  lcd.print("LETS GOOO!!!"); 
  delay(2500);
  lcd.clear();
  lcd.print("Running");
  
 digitalWrite(SV2, "HIGH"); // opens discharge valve
  delay(10000); // waits 10 seconds 

  //Closes Miniflow
   digitalWrite(SV1, "HIGH"); // closes miniflow valve


//Opens Miniflow + Shuts Discharge
  digitalWrite(SV1, "LOW"); // Open MF
  delay(5000);
  
   digitalWrite(SV2, "LOW"); // Shuts discharge
  delay(5000);
  lcd.clear();

delay(300000);
  

  if (distance >= 4)
  lcd.print("Draining");
 
//Turns on DP + Valve
  digitalWrite(SV3, "HIGH"); // Opens Drain valve and starts diaphragm pump
  delay(5000);
   digitalWrite(SV3, "LOW");
  lcd.clear();
  }
  
  }  
  }
  digitalWrite(SV1, "LOW"); // Open MF

digitalWrite() expects HIGH or LOW as a parameter, not a string like "LOW"

If you use the Autoformat tool in the IDE, it may show you where you have (or have not) used { braces } to inform the structure of your algorithm.

Just reading a little bit, looks like you don't have the ifs and elses just right yet.

a7

Thanks guys got me on the right track, sequence is good now just need to clean up the, fill / drain to distance part.