NEED HELP FAST!!!!!

hello!

I dont understand this error that i keep gettin while i verify .

Projet_canon2.ino: In function 'void loop()':
Projet_canon2:26: error: expected `)' before ';' token

#include <Servo.h>
#include <math.h>
Servo myservo;

void setup()

{
myservo.attach(17);
pinMode (45,INPUT);
Serial.begin(9600);

}

int tension1;
int tension2;
int angle;
void loop()
{

tension1 =analogRead(45);
Serial.print("distance: ");
Serial.println((tension1+1)/2);
delay(3000);
tension2 =analogRead(45);
Serial.print("distance: ");
Serial.println((tension2+1)/2);
if (((tension1+1)/2)==((tension2+1)/2);
{
myservo.write (90-((asin(((tension1+1)/2)/60))/2));
delay(1000);
analogWrite(44,HIGH);
delay(10);
analogWrite(44,LOW);
delay(10000);
}

}

need help asap!
Thanks!

Read this before posting a programming question

You failed at matching the proper number of ('s with the correct number of )'s

Try: if (((tension1+1)/2)==((tension2+1)/2)); not: if (((tension1+1)/2)==((tension2+1)/2);

Lefty

oh and also he did this

if (blabla==blblblb); { }
note that red ; is wrong

if (your logical test here){actions sperated by; like another one here;}

if you logical test is more complex you can nest them like this if((a==b)||(c==d)){do things;}

He was probably coding too fast, and is why he needs help fast. :smiley:

Lefty

Code tags and proper formatting would help with all that. Hint.

  tension1 =analogRead(45);

Which Arduino has analog input on pin 45?

CTRL-T

Maybe one of CrossRoads "Barb barb barb, barb barbra arand" boards?

Sorry, I can't help myself sometimes.

Lefty

retrolefty:
Maybe one of CrossRoads "Barb barb barb, barb barbra arand" boards?

Sorry, I can't help myself sometimes.

Lefty

Thought you'd take a chance. :grin:

The mismatched parens would be a lot easier to catch if you simplified the expressions, too. Instead of this:

if (((tension1+1)/2)==((tension2+1)/2);

do this:

if (tension1 == tension2)
{
  do stuff
}

Alternatively, you could use a couple of other variables:

int distance1;
int distance2;
distance1 = (tension1+1)/2;
distance2 = (tension2+1)/2;

and then directly compare distance1 and distance2. This might be the better way to go, as you use the tension1 expression at least three times in the code you posted--use it once to define distance1, and then use distance1 in the other places.

Similarly, this monstrosity:

(90-((asin(((tension1+1)/2)/60))/2))

could be simplified using the distance1 variable to this:

(90-((asin(distance1/60))/2))

...and possibly further, but looking at it makes my brain hurt.