Potted plant watering system. (Involves water pumps.)

Eurika!

Is this it?

/*
    Automamtic plant pot watering system.
    
    Concept:
    Daily or weekly it waters plant pots.
    Sensors detect if the saucer under the pot is
    full or not, and stop the pump when it detects
    the water depth.
    There is also a "timeout" period per pot incase
    there is a problem with filling the pot.
    
*/

#include <arduino.h>
#include <Wire.h>
#include <stdio.h>
#include "DS1307_1.h" 
#include "alarm_clock.h"


//  Array for each pot's fill time
int sol_run_time[5];
//  Array for the values for the system to look for to indicate "full"
int level[6];
//  Solenoid array
int solenoid[5];
//  Sensor array
int sensor[6];


//  These are the sensors for each pot and the main reserve
#define sensorPins[0] 14
#define sensorPins[1] 15
#define sensorPins[2] 16
#define sensorPins[3] 17
#define sensorPins[4] 18
#define sensorPins[5] 19



//  These are the pins to drive each solenoid for each pot.
//  They are OR'd together to turn on the motor/pump.
//int solenoid[5];
#define solenoidPins[1] 0
#define solenoidPins[2] 1
#define solenoidPins[3] 2
#define solenoidPins[4] 3
#define solenoidPins[5] 4



#define LED 5
#define btn_1 6

//  Set time for daily run.
//int run_time_dow 2;
int run_time_hr = 12;
int run_time_mn = 00;
//int run_time_sec = 00;

// RTC stuff
int rtc[7];
DS1307 RTC=DS1307();             // Create RTC object


//#define setRTC
#ifdef setRTC
// Set/init RTC
  RTC.stop();
  RTC.set(DS1307_SEC,0);
  RTC.set(DS1307_MIN,50);
  RTC.set(DS1307_HR,0);
  RTC.set(DS1307_DOW,3);           // value from 1 to 7. User define whether 1 is sun or mon.
  RTC.set(DS1307_DATE,10);
  RTC.set(DS1307_MTH,06);
  RTC.set(DS1307_YR,12);
  RTC.start();
#endif


void setup()
{
    //
    pinMode(sensor[0],INPUT);
    pinMode(sensor[1],INPUT);
    pinMode(sensor[2],INPUT);
    pinMode(sensor[3],INPUT);
    pinMode(sensor[4],INPUT);
    pinMode(sensor[5],INPUT);

    pinMode(btn_1,INPUT);    
    
    pinMode(solenoid[1],OUTPUT);
    pinMode(solenoid[2],OUTPUT);
    pinMode(solenoid[3],OUTPUT);
    pinMode(solenoid[4],OUTPUT);
    pinMode(solenoid[5],OUTPUT);

    pinMode(LED,OUTPUT);
    
    digitalWrite(LED,LOW);
    digitalWrite(solenoid[1],LOW);
    digitalWrite(solenoid[2],LOW);
    digitalWrite(solenoid[3],LOW);
    digitalWrite(solenoid[4],LOW);
    digitalWrite(solenoid[5],LOW);

    // Time in seconds each pot takes to be "filled".
    //  All values to be set.
    sol_run_time[1] = 20;
    sol_run_time[2] = 20;
    sol_run_time[3] = 20;
    sol_run_time[4] = 20;
    sol_run_time[5] = 20;
    
    //  All values to be set.
    level[1] = 20;
    level[2] = 20;
    level[3] = 20;
    level[4] = 20;
    level[5] = 20;
    level[6] = 20;      //  This will be the main reserve, and when it is empty rather than full.

}

void loop()
{
    //  Get time from RTC.
    int rtc[7];
    RTC.get(rtc,true);
    int flag;
    //  Have time, check what time it is.
    if (btn_1 == HIGH)
    {
        Solenoid();
    }
    //
    if (rtc[2] == run_time_hr)
    {
        if (rtc[1] == run_time_mn)
        {
            if (flag == 0)
            {
                //
                Solenoid();
                flag = 1;
            }
        }
    }
    
}

//*************************************************************************************************

void Solenoid()
{
    int i;
    for (i=0;i<5;i++)
    {
        //  Get time value for i
        //  Turn on soldenoid i
        //  Wait the specified time
        //  Check sensor for input
        //  Abort if active
        //  Turn off solenoid i
        digitalWrite(solenoid[i],HIGH);
        sensor_delay(i);
    }
}

//*************************************************************************************************

int sensor_delay(int x)
{
    //  Read threashold values for all sensors.
    //  i is current one, but Main gets read every time anyway.
    int i = x;
    int reading;
    int TTG;
    int time_up;
    TTG = sol_run_time[i];
    time_up = timer(TTG);
    if (time_up > 0)
    {
        reading = digitalRead(sensor[0]);
        if (reading > level[6])      //  Main reserve is good.
        {
            reading = digitalRead(sensor[i]);
            if (reading > level[i])
            {
                //  Water level reached.  Stop pumping and go to next plant.
                TTG = 0;
                digitalWrite(solenoid[i],LOW);
            }
            //  This is if the plant's water is already good
        }
        //  This is if the main level is not good.
    }
    // time_up = 0
}
//return 0;
    
//*************************************************************************************************
    
int timer(int foo)
{
    static int counter;
    counter = foo;
    int rtc[7];
    int min_flag;
    RTC.get(rtc,true);
        if (counter >0)
        {
           if (min_flag != rtc[1])
           {
               min_flag = rtc[1];
               counter = counter - 1;
           }
        }
    return counter;
}

//*************************************************************************************************

It complies ok.