SHARE
TWEET

Untitled

a guest Jun 18th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <DS3231.h>
  2. #include <Wire.h>
  3. #include <LiquidCrystal.h>
  4. DS3231  rtc(SDA, SCL);
  5.  
  6.  
  7. LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
  8. int x = 45;
  9. int y = 47;
  10. int z = 41;
  11. int w = 43;
  12.  
  13. int WaterIn =  40;
  14. int WaterOut = 42;
  15.  
  16. int Pump1 = 25;
  17. int Pump2 = 24;
  18. int Pump3 = 27;
  19.  
  20. void setup()
  21. {
  22.   rtc.begin();
  23.   lcd.begin(16,2);
  24.   // Start the I2C interface
  25.   Wire.begin();
  26.   // Start the serial interface
  27.   Serial.begin(9600);
  28.   //rtc.setDOW(TUESDAY);     // Set Day-of-Week to SUNDAY
  29.   //rtc.setTime(1, 15, 0);     // Set the time to 12:00:00 (24hr format)
  30.   //rtc.setDate(6, 6, 2017);   // Month, Day, Year
  31.  
  32.  //Setup FLoat Switch Pins
  33.   pinMode (x, INPUT);
  34.   pinMode (y, INPUT);
  35.   pinMode (z, INPUT);
  36.   pinMode (w, INPUT);
  37.  
  38.  //Setup Irrigation Valves    
  39.   pinMode(WaterIn, OUTPUT);  //irrigation "in" valve
  40.   pinMode(WaterOut, OUTPUT);  //irrigation "out" valve
  41.  
  42. //Setup Pumps    
  43.   pinMode(Pump1, OUTPUT);  
  44.   pinMode(Pump2, OUTPUT);  
  45.   pinMode(Pump3, OUTPUT);    
  46. }  // end of setup
  47.  
  48. void Calendar(){
  49.  
  50.  lcd.setCursor(0,0);
  51.  lcd.print("Real Time Clock  ");
  52.  lcd.setCursor(0,1);
  53.  lcd.print("Time: ");
  54.  lcd.print(rtc.getTimeStr());
  55.  delay(1000);
  56.  lcd.setCursor(0,1);
  57.  lcd.print("Date: ");
  58.  lcd.print(rtc.getDateStr());
  59.  delay(1000);
  60.  lcd.setCursor(0,1);
  61.  lcd.print("Day: ");
  62.  lcd.print(rtc.getDOWStr());
  63.  lcd.print("           ");
  64.  delay(1000);
  65.  lcd.setCursor(0,1);
  66.  lcd.print("Temp: ");
  67.  
  68.  lcd.print(rtc.getTemp());
  69.  lcd.print(" C");
  70.  lcd.print("          ");
  71.  delay(1000);
  72. }  // end of setup  
  73.  
  74. void Valves(){
  75.   int pinToTurnHigh = 24;
  76.   if ((x == HIGH) && (y == HIGH) && (z == HIGH) && (w == LOW))  //Condition 1
  77.  {
  78.         pinToTurnHigh = WaterIn;
  79.         pinToTurnHigh = Pump1;
  80.         pinToTurnHigh = Pump2;
  81.         pinToTurnHigh = Pump3;
  82.  }      
  83.  if ((x == LOW) && (y == LOW) && (z == HIGH) && (w == HIGH))  //Condition 2
  84.  {
  85.        pinToTurnHigh = WaterOut;
  86.  }
  87.   resetAllPumpValve();
  88.   digitalWrite(pinToTurnHigh, HIGH);
  89.  }  // end of setup
  90.  
  91.  void resetAllPumpValve(){
  92.         digitalWrite(WaterIn, LOW);
  93.         digitalWrite(Pump1, LOW);
  94.         digitalWrite(Pump2, LOW);
  95.         digitalWrite(Pump3, LOW);
  96.         digitalWrite(WaterOut, LOW);
  97.  
  98. }  // end of setup  
  99. void loop()
  100. {
  101.   Calendar();
  102.   Valves();
  103.   resetAllPumpValve();  
  104. }  // end of loop
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top