whats wrong

wont compile why?

   //  Some macros for defining time intervals in milliseconds
#define seconds_in_ms(s) ((s)*1000UL)
#define minutes_in_ms(m) ((m)*60UL*1000UL)
#define hours_in_ms(h)   ((h)*60UL*60UL*1000UL)
#define days_in_ms(d)    ((d)*24UL*60UL*60UL*1000UL)
#define weeks_in_ms(w)   ((w)*7UL*24UL*60UL*60UL*1000UL)
#define PHIN  A0
unsigned long CycleStartTime = 0;
unsigned long LastTaskTime = 0;
unsigned long CurrentTaskInterval = 0;
unsigned Task = 3;


void setup()
{
  pinMode(PHIN,INPUT);
  Serial.begin(9600);
  Serial.println("Welcome SW-02-010A");

{


pinMode(2, OUTPUT);  //PH down
pinMode(3, OUTPUT);  //B nutrient solution
pinMode(4, OUTPUT);  //A nutrient solution
pinMode(5, OUTPUT);  //Drain pump
pinMode(6, OUTPUT);  //Solenoid Valve
pinMode(7, OUTPUT);  //Nutrient Heater
pinMode(8, OUTPUT);  //Not used Future Nutrient/PH contoller

digitalWrite(2, HIGH);  //PH down off
digitalWrite(3, HIGH);  //B nutrient solution off
digitalWrite(4, HIGH);  //A nutrient solution off
digitalWrite(5, HIGH);  //Drain pump off
digitalWrite(6, HIGH);  //Solenoid Valve off
digitalWrite(7, HIGH);  //Nutrient Heater off


void loop() 

{

  unsigned long currentTime = millis();

  // If the time has not yet come to perform a task
  if (currentTime - LastTaskTime >= CurrentTaskInterval)
  LastTaskTime = currentTime;

  switch (Task)
  {
  case 0:
    CycleStartTime = currentTime;  // Remember this time

   digitalWrite(5,LOW);   // set the drain pump on flush

    CurrentTaskInterval = minutes_in_ms(16);
    break;

  case 1:
digitalWrite(5,HIGH);   // set the drain pump off flush
digitalWrite(6,LOW); // set the Solenoid Valve on flush
  CurrentTaskInterval = minutes_in_ms(16);
 break;

 case 2:
digitalWrite(6,HIGH); // set the Solenoid Valve off flush
digitalWrite(7,LOW); // set the Nutrient Heater on flush
    CurrentTaskInterval = hours_in_ms(1);
 break;

 case 3:
digitalWrite(5,LOW);   // set the drain pump on
digitalWrite(7,HIGH); // set the Nutrient Heater off
  CurrentTaskInterval = minutes_in_ms(16);
 break;

  case 4:
digitalWrite(5,HIGH);   // set the drain pump off
digitalWrite(6,LOW); // set the Solenoid Valve on
digitalWrite(2,LOW);  // set the PH down on
digitalWrite(3,LOW); // set the B nutrient solution on
digitalWrite(4,LOW); // set the A nutrient solution on
  CurrentTaskInterval = seconds_in_ms(10);
 break;


case 5:
digitalWrite(2,HIGH);  // set the PH down off
digitalWrite(6,LOW); // set the Solenoid Valve on
digitalWrite(3,LOW); // set the B nutrient solution on
digitalWrite(4,LOW); // set the A nutrient solution on
  CurrentTaskInterval = minutes_in_ms(6);
break;


case 6:
digitalWrite(3,HIGH); // set the B nutrient solution off
digitalWrite(6,LOW); // set the Solenoid Valve on
digitalWrite(4,LOW); // set the A nutrient solution on
    CurrentTaskInterval = minutes_in_ms(5.04);
break;


case 7:
digitalWrite(4,HIGH); // set the A nutrient solution off
digitalWrite(6,LOW); // set the Solenoid Valve on
    CurrentTaskInterval = minutes_in_ms(5);
break;


case 8:
digitalWrite(6,HIGH); // set the Solenoid Valve off
digitalWrite(7,LOW); // set the Nutrient Heater on
digitalWrite(8,HIGH); // set the Future Nutrient/PH contoller
{
  int phRaw;
  float phTmp, phOut, phMiliVolts;
  
  if(Serial.available() )
  {

  }
  phRaw = readADC(PHIN, 16666);    //Our averaged raw ADC value over ~ a single 60hz cycle
  phTmp = (5*(float)phRaw)/1023;   //Convert reading into a voltage based on a 5v reference
  phMiliVolts = phTmp * 1000;      //convert to milivolts
  phTmp = (2500-phMiliVolts)/5.25; //Since our circuit contains an initial gain, we must remove it here
  phOut = 7-(phTmp/59.16);            //ph is the numbers of "steps" from 7 (a step = mV/steps_per_mV)
  Serial.print("ADC1 Raw: ");
  Serial.println(phRaw);
  Serial.print("ADC1 Milivolts: ");
  Serial.println(phMiliVolts);
  Serial.print("pH: ");
  Serial.println(phOut);
  delay(1000); //1 sec
}
//pHduino avaerage routine, very effective for smoothing the readings
//alternatively you could perform software pass filtering here as well.
unsigned int readADC(int channel, unsigned reading_time)
{
  double d;
  int i;
  unsigned long t0_us;
  d = 0.0;
  i = 0;
  t0_us = micros();
  while((micros()-t0_us)<reading_time){
    i++;
    d += analogRead(channel);
  }
  d /= i;
  return (unsigned int)(d);  
}
CurrentTaskInterval = days_in_ms(1);
break;

case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
digitalWrite(6,LOW); // set the Solenoid Valve on/ top up
CurrentTaskInterval = seconds_in_ms(20);
digitalWrite(6,HIGH); // set the Solenoid Valve off/ top up
CurrentTaskInterval = days_in_ms(1);
break;

case 22:
// Start over again in one week from the START of the cycle
    LastTaskTime = CycleStartTime;
    CurrentTaskInterval = weeks_in_ms(1);
    Task = 0;   //starts loop
    break;
  }
}

Please tell us your setup and your error messages. We can't help unless you do!

-TECman-

TECman, please stop the knee-jerk posts. The compilation error is an obvious missing brace (probably two) at the end of setup. The board type, IDE etc is immaterial.

@OP braces {} have to match. I don't know where readADC comes from.

Ok I don’t want so sound dumb But I don’t see it
It just doesn’t like the
void setup()
{
Missing a brace probably, I buy that, but where?.

Before "void loop ()"

Looks to me like you have 2 opening braces in setup, and no closing braces. Why you have 2 opening braces makes no sense to me...

You're missing two closing braces in setup, although the second opening one is not necessary:

void setup()
{
  pinMode(PHIN,INPUT);
  Serial.begin(9600);
  Serial.println("Welcome SW-02-010A");

{  //Not needed

This works I didn’t write it, I’m trying to integrate it into my program.
I’m getting an read ADC was not declared in this scope
along with missing braces.

#define PHIN  A0

void setup()  
{
  pinMode(PHIN,INPUT);
  Serial.begin(9600);
  Serial.println("Welcome SW-02-010A");
}

void loop()
{
  int phRaw;
  float phTmp, phOut, phMiliVolts;
  
  if(Serial.available() )
  {

  }
  phRaw = readADC(PHIN, 16666);    //Our averaged raw ADC value over ~ a single 60hz cycle
  phTmp = (5*(float)phRaw)/1023;   //Convert reading into a voltage based on a 5v reference
  phMiliVolts = phTmp * 1000;      //convert to milivolts
  phTmp = (2500-phMiliVolts)/5.25; //Since our circuit contains an initial gain, we must remove it here
  phOut = 7-(phTmp/59.16);            //ph is the numbers of "steps" from 7 (a step = mV/steps_per_mV)
  Serial.print("ADC1 Raw: ");
  Serial.println(phRaw);
  Serial.print("ADC1 Milivolts: ");
  Serial.println(phMiliVolts);
  Serial.print("pH: ");
  Serial.println(phOut);
  delay(1000); //1 sec
}
//pHduino avaerage routine, very effective for smoothing the readings
//alternatively you could perform software pass filtering here as well.
unsigned int readADC(int channel, unsigned reading_time)
{
  double d;
  int i;
  unsigned long t0_us;
  d = 0.0;
  i = 0;
  t0_us = micros();
  while((micros()-t0_us)<reading_time){
    i++;
    d += analogRead(channel);
  }
  d /= i;
  return (unsigned int)(d);  
}

doing this

 //  Some macros for defining time intervals in milliseconds
#define seconds_in_ms(s) ((s)*1000UL)
#define minutes_in_ms(m) ((m)*60UL*1000UL)
#define hours_in_ms(h)   ((h)*60UL*60UL*1000UL)
#define days_in_ms(d)    ((d)*24UL*60UL*60UL*1000UL)
#define weeks_in_ms(w)   ((w)*7UL*24UL*60UL*60UL*1000UL)
#define PHIN  A0
unsigned long CycleStartTime = 0;
unsigned long LastTaskTime = 0;
unsigned long CurrentTaskInterval = 0;
unsigned Task = 3;


void setup()
{
 
pinMode(2, OUTPUT);  //PH down
pinMode(3, OUTPUT);  //B nutrient solution
pinMode(4, OUTPUT);  //A nutrient solution
pinMode(5, OUTPUT);  //Drain pump
pinMode(6, OUTPUT);  //Solenoid Valve
pinMode(7, OUTPUT);  //Nutrient Heater
pinMode(8, OUTPUT);  //Not used Future Nutrient/PH contoller

digitalWrite(2, HIGH);  //PH down off
digitalWrite(3, HIGH);  //B nutrient solution off
digitalWrite(4, HIGH);  //A nutrient solution off
digitalWrite(5, HIGH);  //Drain pump off
digitalWrite(6, HIGH);  //Solenoid Valve off
digitalWrite(7, HIGH);  //Nutrient Heater off
}

void loop() 

{

  unsigned long currentTime = millis();

  // If the time has not yet come to perform a task
  if (currentTime - LastTaskTime >= CurrentTaskInterval)
  LastTaskTime = currentTime;

  switch (Task)
  {
  case 0:
    CycleStartTime = currentTime;  // Remember this time

   digitalWrite(5,LOW);   // set the drain pump on flush

    CurrentTaskInterval = minutes_in_ms(16);
    break;

  case 1:
digitalWrite(5,HIGH);   // set the drain pump off flush
digitalWrite(6,LOW); // set the Solenoid Valve on flush
  CurrentTaskInterval = minutes_in_ms(16);
 break;

 case 2:
digitalWrite(6,HIGH); // set the Solenoid Valve off flush
digitalWrite(7,LOW); // set the Nutrient Heater on flush
    CurrentTaskInterval = hours_in_ms(1);
 break;

 case 3:
digitalWrite(5,LOW);   // set the drain pump on
digitalWrite(7,HIGH); // set the Nutrient Heater off
  CurrentTaskInterval = minutes_in_ms(16);
 break;

  case 4:
digitalWrite(5,HIGH);   // set the drain pump off
digitalWrite(6,LOW); // set the Solenoid Valve on
digitalWrite(2,LOW);  // set the PH down on
digitalWrite(3,LOW); // set the B nutrient solution on
digitalWrite(4,LOW); // set the A nutrient solution on
  CurrentTaskInterval = seconds_in_ms(10);
 break;


case 5:
digitalWrite(2,HIGH);  // set the PH down off
digitalWrite(6,LOW); // set the Solenoid Valve on
digitalWrite(3,LOW); // set the B nutrient solution on
digitalWrite(4,LOW); // set the A nutrient solution on
  CurrentTaskInterval = minutes_in_ms(6);
break;


case 6:
digitalWrite(3,HIGH); // set the B nutrient solution off
digitalWrite(6,LOW); // set the Solenoid Valve on
digitalWrite(4,LOW); // set the A nutrient solution on
    CurrentTaskInterval = minutes_in_ms(5.04);
break;


case 7:
digitalWrite(4,HIGH); // set the A nutrient solution off
digitalWrite(6,LOW); // set the Solenoid Valve on
    CurrentTaskInterval = minutes_in_ms(5);
break;


case 8:
digitalWrite(6,HIGH); // set the Solenoid Valve off
digitalWrite(7,LOW); // set the Nutrient Heater on
digitalWrite(8,HIGH); // set the Future Nutrient/PH contoller
{
  pinMode(PHIN,INPUT);
  Serial.begin(9600);
  Serial.println("Welcome SW-02-010A");
}
{
  int phRaw;
  float phTmp, phOut, phMiliVolts;
  
  if(Serial.available() )
  {

  }
  phRaw = readADC(PHIN, 16666);    //Our averaged raw ADC value over ~ a single 60hz cycle
  phTmp = (5*(float)phRaw)/1023;   //Convert reading into a voltage based on a 5v reference
  phMiliVolts = phTmp * 1000;      //convert to milivolts
  phTmp = (2500-phMiliVolts)/5.25; //Since our circuit contains an initial gain, we must remove it here
  phOut = 7-(phTmp/59.16);            //ph is the numbers of "steps" from 7 (a step = mV/steps_per_mV)
  Serial.print("ADC1 Raw: ");
  Serial.println(phRaw);
  Serial.print("ADC1 Milivolts: ");
  Serial.println(phMiliVolts);
  Serial.print("pH: ");
  Serial.println(phOut);
  delay(1000); //1 sec
}
//pHduino avaerage routine, very effective for smoothing the readings
//alternatively you could perform software pass filtering here as well.
unsigned int readADC(int channel, unsigned reading_time)
{
  double d;
  int i;
  unsigned long t0_us;
  d = 0.0;
  i = 0;
  t0_us = micros();
  while((micros()-t0_us)<reading_time){
    i++;
    d += analogRead(channel);
  }
  d /= i;
  return (unsigned int)(d);  
}
CurrentTaskInterval = days_in_ms(1);
break;

case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
digitalWrite(6,LOW); // set the Solenoid Valve on/ top up
CurrentTaskInterval = seconds_in_ms(20);
digitalWrite(6,HIGH); // set the Solenoid Valve off/ top up
CurrentTaskInterval = days_in_ms(1);
break;

case 22:
// Start over again in one week from the START of the cycle
    LastTaskTime = CycleStartTime;
    CurrentTaskInterval = weeks_in_ms(1);
    Task = 0;   //starts loop
    break;
  }
}

I did point out the missing readADC earlier.

There are misplaced function definitions, readADC() and another I’ve called show_pH(), between case 8 and case 9.

//  Some macros for defining time intervals in milliseconds
#define seconds_in_ms(s) ((s)*1000UL)
#define minutes_in_ms(m) ((m)*60UL*1000UL)
#define hours_in_ms(h)   ((h)*60UL*60UL*1000UL)
#define days_in_ms(d)    ((d)*24UL*60UL*60UL*1000UL)
#define weeks_in_ms(w)   ((w)*7UL*24UL*60UL*60UL*1000UL)
#define PHIN  A0

unsigned long CycleStartTime = 0;
unsigned long LastTaskTime = 0;
unsigned long CurrentTaskInterval = 0;
unsigned Task = 3;

show_pH(void)
{  int phRaw;
   float phTmp, phOut, phMiliVolts;
   if (Serial.available() )
   {
   }
   phRaw = readADC(PHIN, 16666);    //Our averaged raw ADC value over ~ a single 60hz cycle
   phTmp = (5*(float)phRaw)/1023;   //Convert reading into a voltage based on a 5v reference
   phMiliVolts = phTmp * 1000;      //convert to milivolts
   phTmp = (2500-phMiliVolts)/5.25; //Since our circuit contains an initial gain, we must remove it here
   phOut = 7-(phTmp/59.16);            //ph is the numbers of "steps" from 7 (a step = mV/steps_per_mV)
   Serial.print("ADC1 Raw: ");
   Serial.println(phRaw);
   Serial.print("ADC1 Milivolts: ");
   Serial.println(phMiliVolts);
   Serial.print("pH: ");
   Serial.println(phOut);
   delay(1000); //1 sec
}

//pHduino avaerage routine, very effective for smoothing the readings
//alternatively you could perform software pass filtering here as well.

unsigned int readADC(int channel, unsigned reading_time)
{  double d;
   int i;
   unsigned long t0_us;
   d = 0.0;
   i = 0;
   t0_us = micros();
   while ((micros()-t0_us)<reading_time)
   {  i++;
      d += analogRead(channel);
   }
   d /= i;
   return (unsigned int)(d);
}
void setup()
{  pinMode(2, OUTPUT);  //PH down
   pinMode(3, OUTPUT);  //B nutrient solution
   pinMode(4, OUTPUT);  //A nutrient solution
   pinMode(5, OUTPUT);  //Drain pump
   pinMode(6, OUTPUT);  //Solenoid Valve
   pinMode(7, OUTPUT);  //Nutrient Heater
   pinMode(8, OUTPUT);  //Not used Future Nutrient/PH contoller

   digitalWrite(2, HIGH);  //PH down off
   digitalWrite(3, HIGH);  //B nutrient solution off
   digitalWrite(4, HIGH);  //A nutrient solution off
   digitalWrite(5, HIGH);  //Drain pump off
   digitalWrite(6, HIGH);  //Solenoid Valve off
   digitalWrite(7, HIGH);  //Nutrient Heater off
}

void loop()
{  unsigned long currentTime = millis();
   // If the time has not yet come to perform a task
   if (currentTime - LastTaskTime >= CurrentTaskInterval)
      LastTaskTime = currentTime;
   switch (Task)
   {  case 0:
         CycleStartTime = currentTime;  // Remember this time
         digitalWrite(5,LOW);   // set the drain pump on flush
         CurrentTaskInterval = minutes_in_ms(16);
         break;
      case 1:
         digitalWrite(5,HIGH);   // set the drain pump off flush
         digitalWrite(6,LOW); // set the Solenoid Valve on flush
         CurrentTaskInterval = minutes_in_ms(16);
         break;
      case 2:
         digitalWrite(6,HIGH); // set the Solenoid Valve off flush
         digitalWrite(7,LOW); // set the Nutrient Heater on flush
         CurrentTaskInterval = hours_in_ms(1);
         break;
      case 3:
         digitalWrite(5,LOW);   // set the drain pump on
         digitalWrite(7,HIGH); // set the Nutrient Heater off
         CurrentTaskInterval = minutes_in_ms(16);
         break;
      case 4:
         digitalWrite(5,HIGH);   // set the drain pump off
         digitalWrite(6,LOW); // set the Solenoid Valve on
         digitalWrite(2,LOW);  // set the PH down on
         digitalWrite(3,LOW); // set the B nutrient solution on
         digitalWrite(4,LOW); // set the A nutrient solution on
         CurrentTaskInterval = seconds_in_ms(10);
         break;
      case 5:
         digitalWrite(2,HIGH);  // set the PH down off
         digitalWrite(6,LOW); // set the Solenoid Valve on
         digitalWrite(3,LOW); // set the B nutrient solution on
         digitalWrite(4,LOW); // set the A nutrient solution on
         CurrentTaskInterval = minutes_in_ms(6);
         break;
      case 6:
         digitalWrite(3,HIGH); // set the B nutrient solution off
         digitalWrite(6,LOW); // set the Solenoid Valve on
         digitalWrite(4,LOW); // set the A nutrient solution on
         CurrentTaskInterval = minutes_in_ms(5.04);
         break;
      case 7:
         digitalWrite(4,HIGH); // set the A nutrient solution off
         digitalWrite(6,LOW); // set the Solenoid Valve on
         CurrentTaskInterval = minutes_in_ms(5);
         break;
      case 8:
         digitalWrite(6,HIGH); // set the Solenoid Valve off
         digitalWrite(7,LOW); // set the Nutrient Heater on
         digitalWrite(8,HIGH); // set the Future Nutrient/PH contoller
         {  pinMode(PHIN,INPUT);
            Serial.begin(9600);
            Serial.println("Welcome SW-02-010A");
         }
         CurrentTaskInterval = days_in_ms(1);
         break;
      case 9:
      case 10:
      case 11:
      case 12:
      case 13:
      case 14:
      case 15:
      case 16:
      case 17:
      case 18:
      case 19:
      case 20:
      case 21:
         digitalWrite(6,LOW); // set the Solenoid Valve on/ top up
         CurrentTaskInterval = seconds_in_ms(20);
         digitalWrite(6,HIGH); // set the Solenoid Valve off/ top up
         CurrentTaskInterval = days_in_ms(1);
         break;
      case 22:
// Start over again in one week from the START of the cycle
         LastTaskTime = CycleStartTime;
         CurrentTaskInterval = weeks_in_ms(1);
         Task = 0;   //starts loop
         break;
   }
}

Edit: pretty-printed the whole mess so people can read

Tried this still no go, thanks for the help by the way.
I do want it firing up at 8-9 so that’s why its like this.
either end at 9 or continue on until the end where it loops and end there
little over my head but hopefully not too far.

 //  Some macros for defining time intervals in milliseconds
#define seconds_in_ms(s) ((s)*1000UL)
#define minutes_in_ms(m) ((m)*60UL*1000UL)
#define hours_in_ms(h)   ((h)*60UL*60UL*1000UL)
#define days_in_ms(d)    ((d)*24UL*60UL*60UL*1000UL)
#define weeks_in_ms(w)   ((w)*7UL*24UL*60UL*60UL*1000UL)
#define PHIN  A0
unsigned long CycleStartTime = 0;
unsigned long LastTaskTime = 0;
unsigned long CurrentTaskInterval = 0;
unsigned Task = 3;


void setup()
{
 
pinMode(2, OUTPUT);  //PH down
pinMode(3, OUTPUT);  //B nutrient solution
pinMode(4, OUTPUT);  //A nutrient solution
pinMode(5, OUTPUT);  //Drain pump
pinMode(6, OUTPUT);  //Solenoid Valve
pinMode(7, OUTPUT);  //Nutrient Heater
pinMode(8, OUTPUT);  //Not used Future Nutrient/PH contoller

digitalWrite(2, HIGH);  //PH down off
digitalWrite(3, HIGH);  //B nutrient solution off
digitalWrite(4, HIGH);  //A nutrient solution off
digitalWrite(5, HIGH);  //Drain pump off
digitalWrite(6, HIGH);  //Solenoid Valve off
digitalWrite(7, HIGH);  //Nutrient Heater off
}

void loop() 

{

  unsigned long currentTime = millis();

  // If the time has not yet come to perform a task
  if (currentTime - LastTaskTime >= CurrentTaskInterval)
  LastTaskTime = currentTime;

  switch (Task)
  {
  case 0:
    CycleStartTime = currentTime;  // Remember this time

   digitalWrite(5,LOW);   // set the drain pump on flush

    CurrentTaskInterval = minutes_in_ms(16);
    break;

  case 1:
digitalWrite(5,HIGH);   // set the drain pump off flush
digitalWrite(6,LOW); // set the Solenoid Valve on flush
  CurrentTaskInterval = minutes_in_ms(16);
 break;

 case 2:
digitalWrite(6,HIGH); // set the Solenoid Valve off flush
digitalWrite(7,LOW); // set the Nutrient Heater on flush
    CurrentTaskInterval = hours_in_ms(1);
 break;

 case 3:
digitalWrite(5,LOW);   // set the drain pump on
digitalWrite(7,HIGH); // set the Nutrient Heater off
  CurrentTaskInterval = minutes_in_ms(16);
 break;

  case 4:
digitalWrite(5,HIGH);   // set the drain pump off
digitalWrite(6,LOW); // set the Solenoid Valve on
digitalWrite(2,LOW);  // set the PH down on
digitalWrite(3,LOW); // set the B nutrient solution on
digitalWrite(4,LOW); // set the A nutrient solution on
  CurrentTaskInterval = seconds_in_ms(10);
 break;


case 5:
digitalWrite(2,HIGH);  // set the PH down off
digitalWrite(6,LOW); // set the Solenoid Valve on
digitalWrite(3,LOW); // set the B nutrient solution on
digitalWrite(4,LOW); // set the A nutrient solution on
  CurrentTaskInterval = minutes_in_ms(6);
break;


case 6:
digitalWrite(3,HIGH); // set the B nutrient solution off
digitalWrite(6,LOW); // set the Solenoid Valve on
digitalWrite(4,LOW); // set the A nutrient solution on
    CurrentTaskInterval = minutes_in_ms(5.04);
break;


case 7:
digitalWrite(4,HIGH); // set the A nutrient solution off
digitalWrite(6,LOW); // set the Solenoid Valve on
    CurrentTaskInterval = minutes_in_ms(5);
break;


case 8:
digitalWrite(6,HIGH); // set the Solenoid Valve off
digitalWrite(7,LOW); // set the Nutrient Heater on
digitalWrite(8,HIGH); // set the Future Nutrient/PH contoller

//pHduino avaerage routine, very effective for smoothing the readings
//alternatively you could perform software pass filtering here as well.
unsigned int readADC(int channel, unsigned reading_time)
{	double d;
	int i;
	unsigned long t0_us;
	d = 0.0;
	i = 0;
	t0_us = micros();
	while ((micros()-t0_us)<reading_time)
	{	i++;
		d += analogRead(channel);
	}
	d /= i;
	return (unsigned int)(d);
}

show_pH(void)
{	int phRaw;
	float phTmp, phOut, phMiliVolts;
	if (Serial.available() )
	{
	}
	phRaw = readADC(PHIN, 16666);    //Our averaged raw ADC value over ~ a single 60hz cycle
	phTmp = (5*(float)phRaw)/1023;   //Convert reading into a voltage based on a 5v reference
	phMiliVolts = phTmp * 1000;      //convert to milivolts
	phTmp = (2500-phMiliVolts)/5.25; //Since our circuit contains an initial gain, we must remove it here
	phOut = 7-(phTmp/59.16);            //ph is the numbers of "steps" from 7 (a step = mV/steps_per_mV)
	Serial.print("ADC1 Raw: ");
	Serial.println(phRaw);
	Serial.print("ADC1 Milivolts: ");
	Serial.println(phMiliVolts);
	Serial.print("pH: ");
	Serial.println(phOut);
	delay(1000); //1 sec
}


CurrentTaskInterval = days_in_ms(1);
break;

case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
case 20:
case 21:
digitalWrite(6,LOW); // set the Solenoid Valve on/ top up
CurrentTaskInterval = seconds_in_ms(20);
digitalWrite(6,HIGH); // set the Solenoid Valve off/ top up
CurrentTaskInterval = days_in_ms(1);
break;

case 22:
// Start over again in one week from the START of the cycle
    LastTaskTime = CycleStartTime;
    CurrentTaskInterval = weeks_in_ms(1);
    Task = 0;   //starts loop
    break;
  }
}

I think there may be a missing brace after the time comparison at the start of "loop()"

I also suspect showPh needs to be declared void

The code after it is not in a function, so the compiler won't like that either

The grounds are definitely not connected. gcc will allow nested function definitions as an extension, but not in the middle of a switch statement. :grin: