user27363: I think the below logic should work but its throwing error
void setup() {
  Serial.begin(9600);
}

void loop() {
  int soil_moisture = analogRead(A0); // read from analog pin A3
//  int soil_moisture = pinMode(AO);
  Serial.print(“analog value: “);
  if (soil_moisture < 30) {
    Serial.println(“Dry soil”);
  }
  if ((soil_moisture > 300) && (soil_moisture < 700)) {
    Serial.println(“Humid soil”);
  }
  if ((soil_moisture > 700) && (soil_moisture < 950)) {
    Serial.println(“water”);
  }
}

error i get is 
Arduino: 1.6.12 (Mac OS X), Board: "Arduino/Genuino Uno"

analog_soil_moisture_v02.ino:16: error: stray '\342' in program
   Serial.print(“analog value: “);
   ^
analog_soil_moisture_v02.ino:16: error: stray '\200' in program
analog_soil_moisture_v02.ino:16: error: stray '\234' in program
analog_soil_moisture_v02.ino:16: error: stray '\342' in program
analog_soil_moisture_v02.ino:16: error: stray '\200' in program
analog_soil_moisture_v02.ino:16: error: stray '\234' in program
analog_soil_moisture_v02.ino:18: error: stray '\342' in program
     Serial.println(“Dry soil”);
     ^
analog_soil_moisture_v02.ino:18: error: stray '\200' in program
analog_soil_moisture_v02.ino:18: error: stray '\234' in program
analog_soil_moisture_v02.ino:18: error: stray '\342' in program
analog_soil_moisture_v02.ino:18: error: stray '\200' in program
analog_soil_moisture_v02.ino:18: error: stray '\235' in program
analog_soil_moisture_v02.ino:21: error: stray '\342' in program
     Serial.println(“Humid soil”);
     ^
analog_soil_moisture_v02.ino:21: error: stray '\200' in program
analog_soil_moisture_v02.ino:21: error: stray '\234' in program
analog_soil_moisture_v02.ino:21: error: stray '\342' in program
analog_soil_moisture_v02.ino:21: error: stray '\200' in program
analog_soil_moisture_v02.ino:21: error: stray '\235' in program
analog_soil_moisture_v02.ino:24: error: stray '\342' in program
     Serial.println(“water”);
     ^
analog_soil_moisture_v02.ino:24: error: stray '\200' in program
analog_soil_moisture_v02.ino:24: error: stray '\234' in program
analog_soil_moisture_v02.ino:24: error: stray '\342' in program
analog_soil_moisture_v02.ino:24: error: stray '\200' in program
analog_soil_moisture_v02.ino:24: error: stray '\235' in program
/Users/ciastro/Documents/Arduino/analog_soil_moisture_v01/analog_soil_moisture_v02.ino/analog_soil_moisture_v02.ino.ino: In function 'void loop()':
analog_soil_moisture_v02.ino:16: error: 'analog' was not declared in this scope
   Serial.print(“analog value: “);
                   ^
analog_soil_moisture_v02.ino:18: error: 'Dry' was not declared in this scope
     Serial.println(“Dry soil”);
                       ^
analog_soil_moisture_v02.ino:21: error: 'Humid' was not declared in this scope
     Serial.println(“Humid soil”);
                       ^
analog_soil_moisture_v02.ino:24: error: 'water' was not declared in this scope
     Serial.println(“water”);
                       ^
exit status 1
stray '\342' in program

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


user4143: The actual error you are seeing is caused by the use of incorrect quotes in your program. You most likely copied and pasted the code from a website which has replaced the proper quotes with typeset-standard quotes:
    Serial.println(“Humid soil”);

should be:
    Serial.println("Humid soil");

Note the subtle difference in the quite shape. The first set are typesetter's open- and close-quote characters. The latter are just plain double-quotes (shift-2 on a UK keyboard).
There are other special characters in your program that need replacing with the standard ASCII equivalent, as well.

27363: <p>I think the below logic should work but its throwing error</p>

<pre><code>void setup() {
  Serial.begin(9600);
}

void loop() {
  int soil_moisture = analogRead(A0); // read from analog pin A3
//  int soil_moisture = pinMode(AO);
  Serial.print(“analog value: “);
  if (soil_moisture &lt; 30) {
    Serial.println(“Dry soil”);
  }
  if ((soil_moisture &gt; 300) &amp;&amp; (soil_moisture &lt; 700)) {
    Serial.println(“Humid soil”);
  }
  if ((soil_moisture &gt; 700) &amp;&amp; (soil_moisture &lt; 950)) {
    Serial.println(“water”);
  }
}
</code></pre>

<p>error i get is </p>

<pre><code>Arduino: 1.6.12 (Mac OS X), Board: "Arduino/Genuino Uno"

analog_soil_moisture_v02.ino:16: error: stray '\342' in program
   Serial.print(“analog value: “);
   ^
analog_soil_moisture_v02.ino:16: error: stray '\200' in program
analog_soil_moisture_v02.ino:16: error: stray '\234' in program
analog_soil_moisture_v02.ino:16: error: stray '\342' in program
analog_soil_moisture_v02.ino:16: error: stray '\200' in program
analog_soil_moisture_v02.ino:16: error: stray '\234' in program
analog_soil_moisture_v02.ino:18: error: stray '\342' in program
     Serial.println(“Dry soil”);
     ^
analog_soil_moisture_v02.ino:18: error: stray '\200' in program
analog_soil_moisture_v02.ino:18: error: stray '\234' in program
analog_soil_moisture_v02.ino:18: error: stray '\342' in program
analog_soil_moisture_v02.ino:18: error: stray '\200' in program
analog_soil_moisture_v02.ino:18: error: stray '\235' in program
analog_soil_moisture_v02.ino:21: error: stray '\342' in program
     Serial.println(“Humid soil”);
     ^
analog_soil_moisture_v02.ino:21: error: stray '\200' in program
analog_soil_moisture_v02.ino:21: error: stray '\234' in program
analog_soil_moisture_v02.ino:21: error: stray '\342' in program
analog_soil_moisture_v02.ino:21: error: stray '\200' in program
analog_soil_moisture_v02.ino:21: error: stray '\235' in program
analog_soil_moisture_v02.ino:24: error: stray '\342' in program
     Serial.println(“water”);
     ^
analog_soil_moisture_v02.ino:24: error: stray '\200' in program
analog_soil_moisture_v02.ino:24: error: stray '\234' in program
analog_soil_moisture_v02.ino:24: error: stray '\342' in program
analog_soil_moisture_v02.ino:24: error: stray '\200' in program
analog_soil_moisture_v02.ino:24: error: stray '\235' in program
/Users/ciastro/Documents/Arduino/analog_soil_moisture_v01/analog_soil_moisture_v02.ino/analog_soil_moisture_v02.ino.ino: In function 'void loop()':
analog_soil_moisture_v02.ino:16: error: 'analog' was not declared in this scope
   Serial.print(“analog value: “);
                   ^
analog_soil_moisture_v02.ino:18: error: 'Dry' was not declared in this scope
     Serial.println(“Dry soil”);
                       ^
analog_soil_moisture_v02.ino:21: error: 'Humid' was not declared in this scope
     Serial.println(“Humid soil”);
                       ^
analog_soil_moisture_v02.ino:24: error: 'water' was not declared in this scope
     Serial.println(“water”);
                       ^
exit status 1
stray '\342' in program

This report would have more information with
"Show verbose output during compilation"
option enabled in File -&gt; Preferences.
</code></pre>
 4143: <p>The actual error you are seeing is caused by the use of incorrect quotes in your program. You most likely copied and pasted the code from a website which has replaced the proper quotes with typeset-standard quotes:</p>

<pre><code>    Serial.println(“Humid soil”);
</code></pre>

<p>should be:</p>

<pre><code>    Serial.println("Humid soil");
</code></pre>

<p>Note the subtle difference in the quite shape. The first set are typesetter's open- and close-quote characters. The latter are just plain double-quotes (shift-2 on a UK keyboard).</p>

<p>There are other special characters in your program that need replacing with the standard ASCII equivalent, as well.</p>
