Potted plant watering system. (Involves water pumps.)

Thanks.

I've looked and thought I had it.

This is driving me nuts.

Ok, so I make it read something like:
digitalWrite(solenoid_,LOW);
and it should work.
SHOULD!
This is my code now:
```
/
   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"

//  These are the sensors for each pot and the main reserve
#define sensor_Main 14
#define sensor_1 15
#define sensor_2 16
#define sensor_3 17
#define sensor_4 18
#define sensor_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 solenoin[5];
#define solenoid_1 0
#define solenoid_2 1
#define solenoid_3 2
#define solenoid_4 3
#define solenoid_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;

//  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];

// 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_Main,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_Main);
       if (reading > level[6])      //  Main reserve is good.
       {
           reading = digitalRead(sesnor_[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;
   
//*************************************************************************************************
   
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 given me errors.* *What really annoys/upsets me is I am still missing what is going on.* *I can be writing away and it complies. Haven't even got to testing it yet. I do some small changes, and it just falls over in a big heap.* *Errors everywhere.* *V1.cpp: In function 'void Solenoid()':* *V1:160: error: 'solenoid_' was not declared in this scope* *V1.cpp: In function 'int sensor_delay(int)':* *V1:182: error: 'sesnor_' was not declared in this scope* *V1:187: error: 'solenoid_' was not declared in this scope* *V1.cpp: At global scope:* *V1:195: error: expected unqualified-id before 'return'* *Ok:* *'solenoid_ was not declared in this scope.'* *Yeah, because I changed it from solenoid_[1] to solenoid_* _*See this PART of the code referred below:*_ _*_
void loop() {
 // loop from the lowest pin to the highest:
 for (int thisPin = 0; thisPin < pinCount; thisPin++) {
   // turn the pin on:
   digitalWrite(ledPins[thisPin], HIGH);  
   delay(timer);                  
   // turn the pin off:
   digitalWrite(ledPins[thisPin], LOW);

```
Here, [thisPin] is used instead of the [ i ] which I am using in the case. (Spaces optional and added only to make visible.)
I hope I have obeyed the rules, but it doesn't seem to like me.