expected ')' before ';' token

I don’t understand why is it coming again and again.
The error message is always ‘‘expected ‘)’ before ‘;’ token’’.
I don’t get that there is already a ‘)’ before ‘;’ so, why is it saying this over and over again on the last line.
void setup() {
pinMode (A0; OUTPUT); //VCC pin;
pinMode (A1; OUTPUT); //GND pin;
pinMode (A2; INPUT); // receives signal from sensor;
Serial.begin (9600);
}
// the loop routine runs over and over again;
void loop() {
digitalWrite (A0; HIGH);
digitalWrite (A1); LOW);
if () {
(analogRead(CM) < 5);
digitalWrite(8; HIGH); // provide high voltage to digital pin 8;
digitalWrite(9; LOW); //provide low voltage to digital pin 9;
}
}

MYIRSENSOR.ino (467 Bytes)

You seem to have confused semicolons and commas.

digitalWrite (A1); LOW);

Should be like

digitalWrite(A1, LOW);

You also have an if statement whose condition seems to have escaped into the next line. You should look at some example codes and try to learn the syntax.

int CM;
void setup() {
pinMode (A0, OUTPUT); //VCC pin;
pinMode (A1, OUTPUT); //GND pin;
pinMode (A2, INPUT); // receives signal from sensor;
Serial.begin (9600);
}
// the loop routine runs over and over again;
void loop() {
digitalWrite (A0, HIGH);
digitalWrite (A1, LOW);
if (analogRead(CM < 5)){
digitalWrite(8, HIGH); // provide high voltage to digital pin 8;
digitalWrite(9, LOW); //provide low voltage to digital pin 9;
}
}

Pleas use ctrl-T before pasting any code (within code tags) here... it makes things so much more readable....

Hi.
????? Parth_Saini and Saridol

Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thank you.. Tom... :slight_smile:

Hi,
Parth_Saini
You need to look up how the structure of :

pinMode
digitalWrite
analogRead
if

statements, in particular the use of , and ; marks.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
This bit

 pinMode (A0; OUTPUT); //VCC pin;
  pinMode (A1; OUTPUT); //GND pin;

worries me.

Thanks… Tom… :slight_smile:

Hi,
Whose posting is this?
????? Parth_Saini and Saridol

Tom.... :slight_smile:

  if () {
  (analogRead(CM) < 5);

Oops.

@saripdol

 if (analogRead(CM < 5)){

oops.

I don’t understand why this normal thing is not working. I can’t understand why this is always saying expected ‘)’ before ‘;’ token.

int IR_SENSOR_VCC = A2;
int IR_SENSOR_GND = A1;
int IR_SENSOR_OP = A0;
void setup() {
pinMode (IR_SENSOR_VCC, OUTPUT);
pinMode (IR_SENSOR_GND, OUTPUT);
pinMode (IR_SENSOR_OP, INPUT);
Serial.begin (9600);
}
// the loop routine runs over and over again;
void loop() {
digitalWrite (A0, HIGH);
digitalWrite (A1, LOW);
digitalWrite (A2, HIGH);
int duration = pulseIn (IR_SENSOR_OP, HIGH);
int distance = (duration/2)/29.1;
Serial.print (distance);
Serial.println(‘CM’);
if(distance <= 5); (
digitalWrite(8, HIGH); // output high voltage to digital pin 8;
);
else if(distance >= 5); (
digitalWrite(8, LOW); // output low voltage to digital pin 8;
);
}

Because your "if" syntax is wrong in several ways. Do a little Googling ("c if statement") to understand the correct syntax for a c/c++ if/else statement.

The error message gives you the exact line number, and character position of the error...

Regards,
Ray L.

Please don't start new topics when you already have a very similar one open.

This is a good place to start.

Hi,

if(distance <= 5); (
      digitalWrite(8, HIGH); // output high voltage to digital pin 8;
  );
else if(distance >= 5); (
digitalWrite(8, LOW); // output low voltage to digital pin 8;
);

Look up how if statements are constructed. Particularly the use of { } ( ) and ;

Tom… :slight_smile:

Like other members suggested, learn some of the basic syntax of C language.

Try this code, did some changes. Compare the code with yours and see the difference.

int IR_SENSOR_VCC = A2;
int IR_SENSOR_GND = A1;
int IR_SENSOR_OP = A0;
void setup() {
  pinMode (IR_SENSOR_VCC, OUTPUT);
  pinMode (IR_SENSOR_GND, OUTPUT);
  pinMode (IR_SENSOR_OP, INPUT);
  Serial.begin (9600);
}
// the loop routine runs over and over again;
void loop() {
  digitalWrite (A0, HIGH);
  digitalWrite (A1, LOW);
  digitalWrite (A2, HIGH);
  int   duration = pulseIn (IR_SENSOR_OP, HIGH);
  int  distance = (duration / 2) / 29.1;
  Serial.print (distance);
  Serial.println("CM");
  if (distance <= 5) {
    digitalWrite(8, HIGH); // output high voltage to digital pin 8;
  }
  else if (distance >= 5){
    digitalWrite(8, LOW); // output low voltage to digital pin 8;
  }
}
pinMode (IR_SENSOR_GND, OUTPUT);

As Tom already pointed this, are you going to connect some sensors GND to this pin?

Setting LOW to a pin cant be considered as GND. Use the Arduino GND pin instead.

digitalWrite (A0, HIGH);

do you really need this in the loop? can it be moved to setup()? can the external device directly powered from 5v/3.3v pin of Arduino?

Function arguments are separated by commas, not semicolons.
Strings are delimited by double quotes, not single quotes
Statement-lists are surrounded by braces, not parenthesis.
If statements require a condition - an empty set of parenthesis is not admissable.