Stray '\342' in program irrogation system

I have a problem with some code I have found online:

void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}
#define sen1 A0
#define sen2 A1
int led1=3,led2=4,led3=5, pump_rly=2;
void setup()
{
// put your setup code here, to run once:
pinMode(led1,OUTPUT);
pinMode(led2,OUTPUT);
pinMode(led3,OUTPUT);
pinMode(pump_rly,OUTPUT);
digitalWrite(led1,LOW);
digitalWrite(led2,LOW);
digitalWrite(led3,LOW);
digitalWrite(pump_rly,LOW);
Serial.begin(9600);
Serial.println(“automatic irrigation system using arduino”);
}

void loop()
{
// put your main code here, to run repeatedly:
int sen1_value, sen2_value,soil_moisture_level_1,soil_moisture_level_2;
sen1_value = analogRead(sen1);
sen2_value = analogRead(sen2);
soil_moisture_level_1 = map(sen1_value,200,1020,100,1);
soil_moisture_level_2 = map(sen2_value,200,1020,100,1);
Serial.print(“Soil Moisture level in POT 1: “);
Serial.print(soil_moisture_level_1);
Serial.println(‘%’);
Serial.print(“Soil Moisture level in POT 2: “);
Serial.print(soil_moisture_level_2);
Serial.println(‘%’);

if(soil_moisture_level_1<10)
{
digitalWrite(led1,HIGH);
Serial.println(“moisture level in POT 1 is low”);
}
else if(soil_moisture_level_1>90)
{
digitalWrite(led1,LOW);
Serial.println(“moisture level in POT 1 is adquate”);
}

if(soil_moisture_level_2<10)
{
digitalWrite(led2,HIGH);
Serial.println(“moisture level in POT 2 is low”);
}
else if(soil_moisture_level_2>90)
{
digitalWrite(led2,LOW);
Serial.println(“moisture level in POT 2 is adquate”);
}

/* if(sen3_value>500)
{
digitalWrite(led3,HIGH);
Serial.println(“moisture level in POT 3 is low”);
}
else if(sen3_value<50)
{
digitalWrite(led3,LOW);
Serial.println(“moisture level in POT 3 is adquate”);
}*/

if((soil_moisture_level_1<10) || (soil_moisture_level_2<10))
{
Serial.println(“PUMP ON”);
digitalWrite(pump_rly,HIGH);
}

if((soil_moisture_level_1>94) && (soil_moisture_level_2>94))
{
Serial.println(“PUMP OFF”);
digitalWrite(pump_rly,LOW);
}
delay(3000);
}

And I have the error messages:

Arduino:1.8.15 (Windows Store 1.8.49.0) (Windows 10), Płytka:"Arduino Nano, ATmega328P (Old Bootloader)"

sketch_may21e:25:18: error: stray '\342' in program

Serial.println(“automatic irrigation system using arduino”);

              ^

sketch_may21e:25:19: error: stray '\200' in program

Serial.println(“automatic irrigation system using arduino”);

               ^

sketch_may21e:25:20: error: stray '\234' in program

Serial.println(“automatic irrigation system using arduino”);

                ^

sketch_may21e:25:62: error: stray '\342' in program

Serial.println(“automatic irrigation system using arduino”);

                                                          ^

sketch_may21e:25:63: error: stray '\200' in program

Serial.println(“automatic irrigation system using arduino”);

                                                           ^

sketch_may21e:25:64: error: stray '\235' in program

Serial.println(“automatic irrigation system using arduino”);

                                                            ^

sketch_may21e:36:16: error: stray '\342' in program

Serial.print(“Soil Moisture level in POT 1: “);

            ^

sketch_may21e:36:17: error: stray '\200' in program

Serial.print(“Soil Moisture level in POT 1: “);

             ^

sketch_may21e:36:18: error: stray '\234' in program

Serial.print(“Soil Moisture level in POT 1: “);

              ^

sketch_may21e:36:49: error: stray '\342' in program

Serial.print(“Soil Moisture level in POT 1: “);

                                             ^

sketch_may21e:36:50: error: stray '\200' in program

Serial.print(“Soil Moisture level in POT 1: “);

                                              ^

sketch_may21e:36:51: error: stray '\234' in program

Serial.print(“Soil Moisture level in POT 1: “);

                                               ^

sketch_may21e:38:18: error: stray '\342' in program

Serial.println(‘%’);

              ^

sketch_may21e:38:19: error: stray '\200' in program

Serial.println(‘%’);

               ^

sketch_may21e:38:20: error: stray '\230' in program

Serial.println(‘%’);

                ^

sketch_may21e:38:22: error: stray '\342' in program

Serial.println(‘%’);

                  ^

sketch_may21e:38:23: error: stray '\200' in program

Serial.println(‘%’);

                   ^

sketch_may21e:38:24: error: stray '\231' in program

Serial.println(‘%’);

                    ^

sketch_may21e:39:16: error: stray '\342' in program

Serial.print(“Soil Moisture level in POT 2: “);

            ^

sketch_may21e:39:17: error: stray '\200' in program

Serial.print(“Soil Moisture level in POT 2: “);

             ^

sketch_may21e:39:18: error: stray '\234' in program

Serial.print(“Soil Moisture level in POT 2: “);

              ^

sketch_may21e:39:49: error: stray '\342' in program

Serial.print(“Soil Moisture level in POT 2: “);

                                             ^

sketch_may21e:39:50: error: stray '\200' in program

Serial.print(“Soil Moisture level in POT 2: “);

                                              ^

sketch_may21e:39:51: error: stray '\234' in program

Serial.print(“Soil Moisture level in POT 2: “);

                                               ^

sketch_may21e:41:18: error: stray '\342' in program

Serial.println(‘%’);

              ^

sketch_may21e:41:19: error: stray '\200' in program

Serial.println(‘%’);

               ^

sketch_may21e:41:20: error: stray '\230' in program

Serial.println(‘%’);

                ^

sketch_may21e:41:22: error: stray '\342' in program

Serial.println(‘%’);

                  ^

sketch_may21e:41:23: error: stray '\200' in program

Serial.println(‘%’);

                   ^

sketch_may21e:41:24: error: stray '\231' in program

Serial.println(‘%’);

                    ^

sketch_may21e:46:20: error: stray '\342' in program

 Serial.println(“moisture level in POT 1 is low”);

                ^

sketch_may21e:46:21: error: stray '\200' in program

 Serial.println(“moisture level in POT 1 is low”);

                 ^

sketch_may21e:46:22: error: stray '\234' in program

 Serial.println(“moisture level in POT 1 is low”);

                  ^

sketch_may21e:46:53: error: stray '\342' in program

 Serial.println(“moisture level in POT 1 is low”);

                                                 ^

sketch_may21e:46:54: error: stray '\200' in program

 Serial.println(“moisture level in POT 1 is low”);

                                                  ^

sketch_may21e:46:55: error: stray '\235' in program

 Serial.println(“moisture level in POT 1 is low”);

                                                   ^

sketch_may21e:51:20: error: stray '\342' in program

 Serial.println(“moisture level in POT 1 is adquate”);

                ^

sketch_may21e:51:21: error: stray '\200' in program

 Serial.println(“moisture level in POT 1 is adquate”);

                 ^

sketch_may21e:51:22: error: stray '\234' in program

 Serial.println(“moisture level in POT 1 is adquate”);

                  ^

sketch_may21e:51:57: error: stray '\342' in program

 Serial.println(“moisture level in POT 1 is adquate”);

                                                     ^

sketch_may21e:51:58: error: stray '\200' in program

 Serial.println(“moisture level in POT 1 is adquate”);

                                                      ^

sketch_may21e:51:59: error: stray '\235' in program

 Serial.println(“moisture level in POT 1 is adquate”);

                                                       ^

sketch_may21e:57:20: error: stray '\342' in program

 Serial.println(“moisture level in POT 2 is low”);

                ^

sketch_may21e:57:21: error: stray '\200' in program

 Serial.println(“moisture level in POT 2 is low”);

                 ^

sketch_may21e:57:22: error: stray '\234' in program

 Serial.println(“moisture level in POT 2 is low”);

                  ^

sketch_may21e:57:53: error: stray '\342' in program

 Serial.println(“moisture level in POT 2 is low”);

                                                 ^

sketch_may21e:57:54: error: stray '\200' in program

 Serial.println(“moisture level in POT 2 is low”);

                                                  ^

sketch_may21e:57:55: error: stray '\235' in program

 Serial.println(“moisture level in POT 2 is low”);

                                                   ^

sketch_may21e:62:20: error: stray '\342' in program

 Serial.println(“moisture level in POT 2 is adquate”);

                ^

sketch_may21e:62:21: error: stray '\200' in program

 Serial.println(“moisture level in POT 2 is adquate”);

                 ^

sketch_may21e:62:22: error: stray '\234' in program

 Serial.println(“moisture level in POT 2 is adquate”);

                  ^

sketch_may21e:62:57: error: stray '\342' in program

 Serial.println(“moisture level in POT 2 is adquate”);

                                                     ^

sketch_may21e:62:58: error: stray '\200' in program

 Serial.println(“moisture level in POT 2 is adquate”);

                                                      ^

sketch_may21e:62:59: error: stray '\235' in program

 Serial.println(“moisture level in POT 2 is adquate”);

                                                       ^

sketch_may21e:78:22: error: stray '\342' in program

   Serial.println(“PUMP ON”);

                  ^

sketch_may21e:78:23: error: stray '\200' in program

   Serial.println(“PUMP ON”);

                   ^

sketch_may21e:78:24: error: stray '\234' in program

   Serial.println(“PUMP ON”);

                    ^

sketch_may21e:78:32: error: stray '\342' in program

   Serial.println(“PUMP ON”);

                            ^

sketch_may21e:78:33: error: stray '\200' in program

   Serial.println(“PUMP ON”);

                             ^

sketch_may21e:78:34: error: stray '\235' in program

   Serial.println(“PUMP ON”);

                              ^

sketch_may21e:84:20: error: stray '\342' in program

 Serial.println(“PUMP OFF”);

                ^

sketch_may21e:84:21: error: stray '\200' in program

 Serial.println(“PUMP OFF”);

                 ^

sketch_may21e:84:22: error: stray '\234' in program

 Serial.println(“PUMP OFF”);

                  ^

sketch_may21e:84:31: error: stray '\342' in program

 Serial.println(“PUMP OFF”);

                           ^

sketch_may21e:84:32: error: stray '\200' in program

 Serial.println(“PUMP OFF”);

                            ^

sketch_may21e:84:33: error: stray '\235' in program

 Serial.println(“PUMP OFF”);

                             ^

C:\Users\maciej\Documents\Arduino\sketch_may21e\sketch_may21e.ino: In function 'void setup()':

sketch_may21e:13:6: error: redefinition of 'void setup()'

void setup()

  ^~~~~

C:\Users\maciej\Documents\Arduino\sketch_may21e\sketch_may21e.ino:1:6: note: 'void setup()' previously defined here

void setup() {

  ^~~~~

sketch_may21e:25:21: error: 'automatic' was not declared in this scope

Serial.println(“automatic irrigation system using arduino”);

                 ^~~~~~~~~

C:\Users\maciej\Documents\Arduino\sketch_may21e\sketch_may21e.ino:25:21: note: suggested alternative: 'static'

Serial.println(“automatic irrigation system using arduino”);

                 ^~~~~~~~~

                 static

C:\Users\maciej\Documents\Arduino\sketch_may21e\sketch_may21e.ino: In function 'void loop()':

sketch_may21e:28:6: error: redefinition of 'void loop()'

void loop()

  ^~~~

C:\Users\maciej\Documents\Arduino\sketch_may21e\sketch_may21e.ino:6:6: note: 'void loop()' previously defined here

void loop() {

  ^~~~

sketch_may21e:36:19: error: 'Soil' was not declared in this scope

Serial.print(“Soil Moisture level in POT 1: “);

               ^~~~

C:\Users\maciej\Documents\Arduino\sketch_may21e\sketch_may21e.ino:36:19: note: suggested alternative: 'ceil'

Serial.print(“Soil Moisture level in POT 1: “);

               ^~~~

               ceil

sketch_may21e:38:21: error: expected primary-expression before '%' token

Serial.println(‘%’);

                 ^

sketch_may21e:38:25: error: expected primary-expression before ')' token

Serial.println(‘%’);

                     ^

sketch_may21e:39:24: error: expected ')' before 'Moisture'

Serial.print(“Soil Moisture level in POT 2: “);

                    ^~~~~~~~

sketch_may21e:41:21: error: expected primary-expression before '%' token

Serial.println(‘%’);

                 ^

sketch_may21e:41:25: error: expected primary-expression before ')' token

Serial.println(‘%’);

                     ^

sketch_may21e:46:23: error: 'moisture' was not declared in this scope

 Serial.println(“moisture level in POT 1 is low”);

                   ^~~~~~~~

C:\Users\maciej\Documents\Arduino\sketch_may21e\sketch_may21e.ino:46:23: note: suggested alternative: 'dtostre'

 Serial.println(“moisture level in POT 1 is low”);

                   ^~~~~~~~

                   dtostre

sketch_may21e:51:23: error: 'moisture' was not declared in this scope

 Serial.println(“moisture level in POT 1 is adquate”);

                   ^~~~~~~~

C:\Users\maciej\Documents\Arduino\sketch_may21e\sketch_may21e.ino:51:23: note: suggested alternative: 'dtostre'

 Serial.println(“moisture level in POT 1 is adquate”);

                   ^~~~~~~~

                   dtostre

sketch_may21e:57:23: error: 'moisture' was not declared in this scope

 Serial.println(“moisture level in POT 2 is low”);

                   ^~~~~~~~

C:\Users\maciej\Documents\Arduino\sketch_may21e\sketch_may21e.ino:57:23: note: suggested alternative: 'dtostre'

 Serial.println(“moisture level in POT 2 is low”);

                   ^~~~~~~~

                   dtostre

sketch_may21e:62:23: error: 'moisture' was not declared in this scope

 Serial.println(“moisture level in POT 2 is adquate”);

                   ^~~~~~~~

C:\Users\maciej\Documents\Arduino\sketch_may21e\sketch_may21e.ino:62:23: note: suggested alternative: 'dtostre'

 Serial.println(“moisture level in POT 2 is adquate”);

                   ^~~~~~~~

                   dtostre

sketch_may21e:78:25: error: 'PUMP' was not declared in this scope

   Serial.println(“PUMP ON”);

                     ^~~~

C:\Users\maciej\Documents\Arduino\sketch_may21e\sketch_may21e.ino:78:25: note: suggested alternative: 'PGM_P'

   Serial.println(“PUMP ON”);

                     ^~~~

                     PGM_P

sketch_may21e:84:23: error: 'PUMP' was not declared in this scope

 Serial.println(“PUMP OFF”);

                   ^~~~

C:\Users\maciej\Documents\Arduino\sketch_may21e\sketch_may21e.ino:84:23: note: suggested alternative: 'PGM_P'

 Serial.println(“PUMP OFF”);

                   ^~~~

                   PGM_P

exit status 1

stray '\342' in program

Can someone help me?

All the quotes on your print statements have been transformed by the web page you copied the code from. A bit of find and replace should sort it out.

I am a beginer what do I have to do?

Replace every quote I.e. " with the one on your keyboard. They look ok, but they are not. Do a couple manually at the end of the program and you should have (slightly) fewer errors when you recompile. Rinse and repeat until they are all gone.

thanks works now

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.