ArduinoGeneral

Error Message when verifying sample code in tutorial

userHead Account cancelled 2017-05-25 19:52:18 1443 Views1 Replies
I'm trying to complete a tutorial but I am getting an error message when trying to verify the code.

Error Message:
Arduino: 1.6.5 Hourly Build 2015/05/22 10:13 (Mac OS X), Board: "Arduino Uno"

Temperature_Alarm:7: error: stray '\' in program
Temperature_Alarm:7: error: stray '\' in program
Temperature_Alarm:10: error: stray '\' in program
Temperature_Alarm:10: error: stray '\' in program
Temperature_Alarm:11: error: stray '\' in program
Temperature_Alarm:34: error: stray '\' in program
Temperature_Alarm:34: error: stray '\' in program
Temperature_Alarm:36: error: stray '\' in program
Temperature_Alarm:36: error: stray '\' in program
Temperature_Alarm.ino: In function 'void setup()':
Temperature_Alarm:7: error: 'u3000' was not declared in this scope
Temperature_Alarm:7: error: expected ';' before 'u3000'
Temperature_Alarm.ino: In function 'void loop()':
Temperature_Alarm:10: error: 'u3000' was not declared in this scope
Temperature_Alarm:10: error: expected ';' before 'u3000'
Temperature_Alarm:12: error: expected ';' before 'val'
Temperature_Alarm:13: error: 'value' was not declared in this scope
Temperature_Alarm:13: error: expected ';' before 'from'
Temperature_Alarm:15: error: 'temperature' was not declared in this scope
Temperature_Alarm:15: error: expected ';' before 'value'
Temperature_Alarm:39: error: expected '}' at end of input
stray '\' in program

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

Sample Code:
float sinVal;
int toneVal;
unsigned long tepTimer ;
void setup(){
pinMode(8, OUTPUT); // configure pin of buzzer
Serial.begin(9600); // configure baud rate to 9600 bps
}
void loop(){
int val;    //save the value of LM35
double data;   // save the converted value of temperature
val=analogRead(0); //Connect LM35 to analog pin and read
value from it
data = (double) val * (5/10.24); //Convert the voltage value to
temperature value

if(data>27){ //If temperature is higher than 27, the buzzer starts to
make sound.
for(int x=0; x<180; x++){
//Convert sin function to radian
sinVal = (sin(x*(3.1412/180)));
//Use sin function to generate frequency of sound
toneVal = 2000+(int(sinVal*1000));
//Configure the buzzer pin 8
tone(8, toneVal);
delay(2);
}
} else { // If the temperature is lower than
27, turn off the buzzer
noTone(8); // Turn off the buzzer
}
if(millis() - tepTimer > 50 // Every 500 ms, serial port outputs
temperature value.
tepTimer = millis();
Serial.print("temperature: "); // Serial port outputs temperature
Serial.print(data);    // Serial port outputs temperature
value
Serial.println("C");    // Serial port output temperature
unit
}
}

Tutorial:
https://www.dfrobot.com/blog-600.html

Please help. It's really frustrating when the tutorial provides so little troubleshooting...
2017-06-07 13:31:17 Hi, I met this problem before. This is because some of the chars like space before the comments is typed under Chinese editor. Don't just copy and paste the code, type it by yourself, then the problem would be solved userHeadPic shuaichen_qilin