#define Tank1_Top 34
#define Tank1_Bottom 35 // pin for the float sensor at the bottom of sump
#define Tank2_Top 23 // pin for the float sensor at the top of overhead tank
#define Tank2_Bottom 22// pin for the float sensor at the bottom of overhead tank
#define General_Motor 2
#define OneHP_Motor 4
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(Tank1_Top, INPUT_PULLUP);
pinMode(Tank1_Bottom, INPUT_PULLUP);
pinMode(Tank2_Top, INPUT_PULLUP);
pinMode(Tank2_Bottom, INPUT_PULLUP);
pinMode(General_Motor, OUTPUT);
pinMode(OneHP_Motor, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int Tank1Top_level = digitalRead(Tank1_Top); // 1 if water is present, 0 if not
int Tank1Bottom_level = digitalRead(Tank1_Bottom);
int Tank2Top_level = digitalRead(Tank2_Top);
int Tank2Bottom_level = digitalRead(Tank2_Bottom);
if (Tank1Top_level == 0 && Tank1Bottom_level == 0) {
digitalWrite(General_Motor, LOW);
digitalWrite(OneHP_Motor, LOW);
Serial.println("General Motor:OFF");
Serial.println("OneHP Motor:OFF");
}
else if (Tank1Bottom_level == 1 && Tank2Bottom_level == 0){
digitalWrite(General_Motor, HIGH);
digitalWrite(OneHP_Motor, LOW );
Serial.println("General Motor:ON");
Serial.println("OneHP Motor:OFF");
}
else if (Tank1Bottom_level == 1 && Tank2Bottom_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(1000);
}