Pages: [1]   Go Down
Author Topic: Compile Error on Simple Subtraction  (Read 315 times)
0 Members and 1 Guest are viewing this topic.
Lost Wages
Offline Offline
Full Member
***
Karma: 11
Posts: 103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is a very simple sketch:
Code:
void setup()
{
  Serial.begin(9600);          // debug write to the USB
}

void loop()
{
  int vR = 0;       // reference voltage
  int vP = 0;               // potentiometer voltage
  int x = 0;                       // difference between the two
   
  vR = analogRead(A0);        // read vR to compare with vP
 
  vP = analogRead(A1);        // read vP to compare with vR

  x = vR – vP;                // calculate the difference
 
  Serial.print(x);            // write difference to console
}

Here are the compiler error messages:
minus:17: error: stray '\' in program
minus.ino: In function 'void loop()':
minus:17: error: expected `;' before 'u2013'

If I comment out the
  x = vR – vP;                // calculate the difference
line (17), it compiles OK.

I tried to search existing posts but didn't find an answer.

What gives???
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


https://www.google.com/search?q=error:+stray+%27%5C%27+in+program+site%3Aarduino.cc%2Fforum

http://arduino.cc/forum/index.php/topic,109607.msg823129.html#msg823129
Logged

Lost Wages
Offline Offline
Full Member
***
Karma: 11
Posts: 103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Retyped the minus and it all works! I must have cut n pasted at some point. Many thanks.
Logged

Pages: [1]   Go Up
Jump to: