simple programming but im new

So im very very new to programming im trying to build an automatic watering system for my plants, so the moisture sensor works but i dont really know how to trigger with relay to fire the pump when the moisture sensor detects no water.

int msensor = A1;
int msvalue = 0;
int Relay = 8;
int val;
boolean flag = false;
void setup() {
Serial.begin(9600);
pinMode(msensor, INPUT);
pinMode(Relay, OUTPUT);
}

void loop() {
msvalue = analogRead(msensor);
Serial.println(msvalue);

if ( (msvalue >= 500 ) && ( flag == false ) )
{
digitalWrite(Relay, HIGH);
flag = true;
delay(1000);
}

if ( ( msvalue <= 300 ) && ( flag == true ) )
{
digitalWrite(Relay, LOW);
flag = false;
delay(1000);
}

val = analogRead(A1);{
if ( (msvalue <= 300 == LOW) ;
}
digitalWrite(13,LOW);
{
digitalWrite(13,HIGH);
}
delay(800);
{
}

delay(1000){;
}

WOW, that program layout is a mess

Here it is Auto formatted in the IDE and posted here in code tags

int msensor = A1;
int msvalue = 0;
int Relay = 8;
int val;
boolean flag = false;
void setup()
{
  Serial.begin(9600);
  pinMode(msensor, INPUT);
  pinMode(Relay, OUTPUT);
}

void loop()
{
  msvalue = analogRead(msensor);
  Serial.println(msvalue);
  if ( (msvalue >= 500 ) && ( flag == false ) )
  {
    digitalWrite(Relay, HIGH);
    flag = true;
    delay(1000);
  }
  if ( ( msvalue <= 300 ) && ( flag == true ) )
  {
    digitalWrite(Relay, LOW);
    flag = false;
    delay(1000);
  }
  val = analogRead(A1);
  {
    if ( (msvalue <= 300 == LOW) ;
  }
digitalWrite(13, LOW);
  {
    digitalWrite(13, HIGH);
  }
  delay(800);
  {
  }
  delay(1000)
  {
    ;
  }

You seem to have sprayed { and } around liberally without knowing what they are used for and invented your own syntax such as
    if ( (msvalue <= 300 == LOW) ; I have no idea what that is supposed to do. Needless to say the code does not compile

Start small. Read the sensor and print what it returns

ok thank you :frowning: just got a bit too excited :confused:

the code looks like it should work. Not sure it compiles with

delay(1000){;

suggest you replace everything from

val = analogRead(A1);

thru the end of the file with a closing brace, "}" and set the LED to the same value the you set the Relay whenever you set the Relay.

assume your prints show that msvalue goes above 500 and below 300?

a relay may require more current than an Arduino output can supply. may need a transistor