trigger D13 w/ A0 on Monday and trigger D12 w/A0 on tuesday. etc etc etc

Hi there. I'm using a relay shield, a ds1307 rtc and a yl-69 moisture sensor. My goal is to alternate which pin is being used for each day. i want to activate pin 12 on one day and pin 13 the next but only if the sensor value is below a certain threshold. The idea is to have one pump for food and one pump for water. I have been helped immensely already and wish to further refine this sketch.

So In my head, this code should initialize Pin 13 for 5 seconds before 12 and only if the sensor value is below 400. and when it is after 12, Pin 12 will initialize for 5 seconds but only if the sensor value is met.

My hope in the future is also to be able to base the OUTPUT pins on day of the week or even and odd days.
Right now I have it set to per half day. Any body know how use daysoftheweek instead?

#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13;
int ledPin2 = 12;// select the pin for the LED
int sensorValue = 0;

void setup() {
Serial.begin(9600);
// declare the ledPin as an OUTPUT:
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
}

void loop() {
DateTime now = rtc.now();
if (now.hour() > 12 && analogRead(sensorPin) > 400)
{
digitalWrite(ledPin1, LOW);
delay(5000);
digitalWrite(ledPin1, HIGH);
}
if (now.hour() < 12 && analogRead(sensorPin) > 400)
{
digitalWrite(ledPin2, LOW);
delay(5000);
digitalWrite(ledPin2, HIGH);
}
}

if (now.hour() > 12 && analogRead(sensorPin) > 400);

If the hour is greater than 12 and the analog reading is high enough, do nothing. That's what the ; on the end says. Probably not what you meant.

Ive made those changes and it seems to work better except that when I initially upload the program, both Pins go High, Pin 12 goes LOW after 5 seconds and Pin 13 remains HIGH. If i trigger the sensor, the program will normalize and Pin 13 will go to Normally LOW.

It's better if you don't use the pin with the onboard LED. You have plenty of other pins to choose from.

If you are going to number one variable in an apparent set, it looks dumb not to number all of them. You don't count uh-huh, two, three, do you?

Alright. I have got it looking prettier now. Still getting spooky action off of startup. Pin stays high until I trigger sensorValue?

Pin stays high until I trigger sensorValue?

I really have no idea what this means, since sensorValue is never used in your code.

Since the action is only supposed to happen if the sensor reading is over 400, ALL the code belongs inside the body of an if statement.

void loop()
{
   if(analogRead(sensorPin) > 400)
   {
   }
}

Inside the body of the if statement, get the time, and determine what to do.

In setup(), add digitalWrite() statements to pull the pins LOW, if needed.

Try changing your setup() to:

void setup() {
  Serial.begin(9600);
  digitalWrite(ledPin1, HIGH);
  digitalWrite(ledPin2, HIGH);
  // declare the ledPin as an OUTPUT:
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
}