Go Down

Topic: Compile Error on Simple Subtraction (Read 458 times) previous topic - next topic


Here is a very simple sketch:
Code: [Select]

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???

Coding Badly




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

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131