problem with this....

tons of errors, help!
am totally a newbie

int moistureSensor = 0;
int waterPump = 7;
int moisture_val;
int pin_out = 9;

void setup()
//open serial port
Serial.begin(9600);
pinMode (waterPump, OUTPUT);
digitalWrite (waterPump, LOW);
pinMode(pin_out,OUTPUT);
pinMode(13, OUTPUT);
pinMode(7, OUTPUT);
}
void LedState(int state)
{
void loop()
// read the value from the moisture-sensing probes, print it to screen, and wait a second
moisture_val = analogRead(moistureSensor);
Serial.print("moisture sensor reads ");
Serial.println( moisture_val );
delay(1000);

//turn water on when soil is dry, and delay until soil is wet
if (moisture_val < 850)
}
digitalWrite(waterPump, HIGH);
LedState(HIGH);
digitalWrite(13,LOW);
{

while (moisture_val < 850)
}
delay(10000);
moisture_val = analogRead(moistureSensor);
{

digitalWrite(waterPump, LOW);
LedState(LOW);
digitalWrite(13,HIGH);
digitalWrite(pin_out,HIGH);
delay(10000);
digitalWrite(pin_out,LOW);
delay(10000);
}

You're missing the opening { brace in both setup() and loop()

You've got the braces reversed in both the if and while statements. You've got if( ...) } ..statements ..{ and you should have if (...) {statements}.

I can't see what you're trying to do with void LedState(int state) { - it's like you started defining it then didn't finish. It compiles OK if you remove all references to it though.

Here's a tip to prevent getting into such a mess in future:

Always start with a tiny sketch. Get it working the (limited) way it should work. Then extend it a little bit. Get that working. Add a bit more & debug.

It's an iterative process. Don't make changes that are too big to understand.

Hint : its

void setup() {

do the stuff between the brackets for setup..

}

Keep the same pattern for..

while(something true or false) {

do the stuff between the brackets while its true..

}

if (something true or false) {

do stuff between brackets if its true, skip if not true..

}

That should get you going.

-jim lee

void LedState(int state)
{
void loop()

Don't try to nest function definitions like this.

AWOL:

void LedState(int state)

{
void loop()


Don't try to nest function definitions like this.

Yeah, this ain't Pascal. :slight_smile:

-jim lee