const int relayOne = 12;
const int relayTwo = 11;
const int fsOne = 4;
const int fsTwo = 8;
const int pbOne = 10;
// Set up the variables
int fsOneState = 0;
int fsTwoState = 0;
int pbOneState = 0;
void setup() { // Setup the pins
pinMode(relayOne, OUTPUT);
pinMode(relayTwo, OUTPUT);
pinMode(fsOne, INPUT_PULLUP);
pinMode(fsTwo, INPUT_PULLUP);
pinMode(pbOne, INPUT_PULLUP);
Serial.begin(9600); // Start the Serial Service
}
void loop() { // Read the state of the float switches
fsOneState = digitalRead(fsOne);
fsTwoState = digitalRead(fsTwo);
pbOneState = digitalRead(pbOne);
if (pbOneState == LOW) { // If the button is pressed
if (fsOneState == HIGH) {
digitalWrite(relayOne, HIGH);
Serial.println("Float switch one HIGH");
}
else {
digitalWrite(relayOne, LOW);
Serial.println("Float switch one LOW");
}
if (fsTwoState == HIGH) {
digitalWrite(relayTwo, HIGH);
Serial.println("Float switch two HIGH");
}
else {
digitalWrite(relayTwo, LOW);
Serial.println("Float switch two LOW");
}
delay(100);
}
}