expected ','or ';' before 'void'

i want to perform & operation using pir and ultrasonic sensor i write a code but subject problem occurred during verification of code
kindly guide here is code
#define trigPin 12
#define echoPin 11
#define pirpin 2
int Buzzer = 8; // Connect buzzer pin to 8
int ledPin= 6; //Connect LEd pin to 6
int duration, distance; //to measure the distance and time taken
int pir= 2

void setup(){
Serial.begin (9600);
//Define the output and input objects(devices)
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(pirPin, INPUT);
//pinMode(Buzzer, OUTPUT);
pinMode(ledPin, OUTPUT);

}

void loop() {

digitalRead(pirpin, HIGH)
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
//when distance is greater than or equal to 200 OR less than or equal to 0,the buzzer and LED are off
if (distance >= 200 || distance <= 0) && (pirpin, HIGH)
{
Serial.println(“no object detected”);
//digitalWrite(Buzzer,LOW);
digitalWrite(ledPin,LOW);
}
else
if (distance < 200 || distance > 0) && (pirpin, HIGH)
{
Serial.println(“object detected”);
//digitalWrite(Buzzer,HIGH);
digitalWrite(ledPin,HIGH);
}
else
if (distance < 200 || distance > 0) && (pirpin, LOW)
{
Serial.println(“no object detected”);
//digitalWrite(Buzzer,LOW);
digitalWrite(ledPin,LOW);
}
else
if (distance >= 200 || distance <= 0) && (pirpin, LOW)
{
Serial.println(“no object detected”);
//digitalWrite(Buzzer,LOW);
digitalWrite(ledPin,LOW);
}
}

You are missing a ;
I am sure you can find it.

.

the line

int pir= 2

needs a semicolon at the end.

1 Like

Ahhh, you aren't playing the game.

There might be another one :wink:

.

(deleted)

There is also a capitalization error, read error, and logical comparison problems too.

Hi,
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.

Thanks.. Tom.. :slight_smile: