My gardunio edit and my issues with the delay function

Some empty lines and right indentation can do miracles :slight_smile:

If you have the code in the IDE you should press CTRL-T to re-indent the code to make it more readable.

rewritten the code without delays so it is far more responsive without flooding the serial output - find the differences :wink: - and give it a try

//
//    FILE: garduino.pde
//  AUTHOR: 
//    DATE: 2012-NOV-01
//
// PUPROSE: watering plants
//

#define WATERTHRESHOLD  850
#define LIGHTTHRESHOLD 30
#define OUTPUTINTERVAL 1000

int photocellPin  = A0;     // the cell and pull down are connected to a0 to check for light levels
int WaterSensor = A1;    // Water level sensor

int photocellReading =0;    // the analog reading from the analog resistor divider

int lightarray1 = 13;        // lights for the plants
int waterpump = 7;        // Its the pump for the water
int water_val = 0;               // stores the value for water levels

unsigned long lastOutput = 0;

void setup(void) 
{
  Serial.begin(9600);
  Serial.println("Start garduino...");

  pinMode(lightarray1, OUTPUT);
  pinMode(waterpump, OUTPUT);
  digitalWrite (waterpump, LOW);
}

void loop(void) 
{
  //turn water on when soil appears to be dry stop when the plant is watered
  water_val = analogRead(WaterSensor);
  if (water_val < WATERTHRESHOLD  )
  {
    digitalWrite(waterpump, HIGH);
  }
  else 
  {
    digitalWrite(waterpump, LOW);
  }

  //turn light on when it appears to be dark
  photocellReading = analogRead(photocellPin);
  if (photocellReading < LIGHTTHRESHOLD ) 
  {
    digitalWrite(lightarray1, HIGH);
  }
  else 
  {
    digitalWrite(lightarray1, LOW);
  }

  // DO SERIAL OUTPUT ?
  if (millis() - lastOutput >= OUTPUTINTERVAL)
  {
    lastOutput = millis();
    Serial.print("Water levels at: ");
    Serial.println( water_val );
    Serial.print("Light at : ");
    Serial.print( photocellReading ); // the raw analog reading
  }
}