#define SumpSwitchTop 15
#define SumpSwitchBottom 2 // pin for the float sensor at the bottom of sump
#define TankSwitchTop 4 // pin for the float sensor at the top of overhead tank
#define TankSwitchBottom 5// pin for the float sensor at the bottom of overhead tank
#define General_Motor 22
#define OneHP_Motor 23
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(SumpSwitchTop, INPUT_PULLUP);
pinMode(SumpSwitchBottom, INPUT_PULLUP);
pinMode(TankSwitchTop, INPUT_PULLUP);
pinMode(TankSwitchBottom, INPUT_PULLUP);
pinMode(General_Motor, OUTPUT);
pinMode(OneHP_Motor, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int SumpTop_level = digitalRead(SumpSwitchTop); // 1 if water is present, 0 if not
int SumpBottom_level = digitalRead(SumpSwitchBottom);
int TankTop_level = digitalRead(TankSwitchTop);
int TankBottom_level = digitalRead(TankSwitchBottom);
if (TankTop_level == 0 && TankBottom_level == 0) {
digitalWrite(General_Motor, LOW);
digitalWrite(OneHP_Motor, LOW);
Serial.println("General Motor:OFF");
Serial.println("OneHP Motor:OFF");
}
else if (TankBottom_level == 1 && SumpBottom_level == 0){
digitalWrite(General_Motor, HIGH);
digitalWrite(OneHP_Motor, LOW );
Serial.println("General Motor:ON");
Serial.println("OneHP Motor:OFF");
}
else if (TankBottom_level == 1 && SumpBottom_level == 1){
digitalWrite(General_Motor, LOW);
digitalWrite(OneHP_Motor, HIGH);
Serial.println("General Motor:OFF");
Serial.println("OneHP Motor:ON");
}
else{
Serial.println("No operation");
}
delay(3000);
}