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);
{
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.