My project has 2 valves and 3 pumps. I created the sketch, and uploaded it. But it is not working, all "OUTPUT" are "HIGH". Can you help?
This is my sketch:
#include <DS3231.h>
#include <Wire.h>
#include <LiquidCrystal.h>
DS3231 rtc(SDA, SCL);
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int x = 45;
int y = 47;
int z = 41;
int w = 43;
int WaterIn = 40;
int WaterOut = 42;
int Pump1 = 25;
int Pump2 = 24;
int Pump3 = 27;
void setup()
{
rtc.begin();
lcd.begin(16,2);
// Start the I2C interface
Wire.begin();
// Start the serial interface
Serial.begin(9600);
//rtc.setDOW(TUESDAY); // Set Day-of-Week to SUNDAY
//rtc.setTime(1, 15, 0); // Set the time to 12:00:00 (24hr format)
//rtc.setDate(6, 6, 2017); // Month, Day, Year
//Setup FLoat Switch Pins
pinMode (x, INPUT);
pinMode (y, INPUT);
pinMode (z, INPUT);
pinMode (w, INPUT);
//Setup Irrigation Valves
pinMode(WaterIn, OUTPUT); //irrigation "in" valve
pinMode(WaterOut, OUTPUT); //irrigation "out" valve
//Setup Pumps
pinMode(Pump1, OUTPUT);
pinMode(Pump2, OUTPUT);
pinMode(Pump3, OUTPUT);
} // end of setup
void Calendar(){
lcd.setCursor(0,0);
lcd.print("Real Time Clock ");
lcd.setCursor(0,1);
lcd.print("Time: ");
lcd.print(rtc.getTimeStr());
delay(1000);
lcd.setCursor(0,1);
lcd.print("Date: ");
lcd.print(rtc.getDateStr());
delay(1000);
lcd.setCursor(0,1);
lcd.print("Day: ");
lcd.print(rtc.getDOWStr());
lcd.print(" ");
delay(1000);
lcd.setCursor(0,1);
lcd.print("Temp: ");
lcd.print(rtc.getTemp());
lcd.print(" C");
lcd.print(" ");
delay(1000);
} // end of setup
void Valves(){
int pinToTurnHigh = 24;
if ((x == HIGH) && (y == HIGH) && (z == HIGH) && (w == LOW)) //Condition 1
{
pinToTurnHigh = WaterIn;
pinToTurnHigh = Pump1;
pinToTurnHigh = Pump2;
pinToTurnHigh = Pump3;
}
if ((x == LOW) && (y == LOW) && (z == HIGH) && (w == HIGH)) //Condition 2
{
pinToTurnHigh = WaterOut;
}
resetAllPumpValve();
digitalWrite(pinToTurnHigh, HIGH);
} // end of setup
void resetAllPumpValve(){
digitalWrite(WaterIn, LOW);
digitalWrite(Pump1, LOW);
digitalWrite(Pump2, LOW);
digitalWrite(Pump3, LOW);
digitalWrite(WaterOut, LOW);
} // end of setup
void loop()
{
Calendar();
Valves();
resetAllPumpValve();
} // end of loop