how to interface 2 ir sensor and servo motor please help..!!

I have a code for the above, Everything is fine, the connections status but the servo motor is not moving .please tell me if my code is correct. Can we use pinMode command as many no. of times? Or is there some other problem.
Here is my code:-

int button =10;
int ir_sensor =11 ;
int ir_sonsor =12;
int pos = 0; // variable to store the servo position
void setup()
{
pinMode(ir_sensor, INPUT);
pinMode(ir_sonsor,INPUT);
myservo.attach(9);
digitalWrite(ir_sensor, LOW);
digitalWrite(ir_sonsor, LOW);
Serial.begin(9600);
}
void loop()
{
if(digitalRead(ir_sensor || ir_sonsor)==HIGH)
{
if(key_1==1)
{
key_1=0;
Serial.println(“DOOR OPEN”);
for(pos = 0; pos < 120; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15);
}
delay(2000);
}

while(digitalRead(ir_sensor || ir_sonsor)==HIGH);
}
else
{
if(key_1==0)
{
key_1=1;
Serial.println(“DOOR CLOSE”);
for(pos = 90; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15);
}

}
while(digitalRead(ir_sensor || ir_sonsor)==LOW);
}
}

Have you compiled that program?

Paul

yes it is compiled successfully

Srijan_Bakshi:
yes it is compiled successfully

Not the code you posted. I just tried it.

Paul

#include <Servo.h>
int key_1;

Servo myservo;

add this in the beginning then it will run

It may be the "for" loops. The examples do not show "+=" or "-=".

Paul

digitalRead(ir_sensor || ir_sonsor)Oops

Please remember to use code tags when posting code

  if (digitalRead(ir_sensor || ir_sonsor) == HIGH)

I think you mean:

  if (digitalRead(ir_sensor) == HIGH || digitalRead(ir_sonsor) == HIGH)

Okay, sir, I will try this thank you_/_

sir, it is now working but both are working together i want to operate from one sensor at a time..!!

Srijan_Bakshi:
sir, it is now working but both are working together i want to operate from one sensor at a time..!!

Please post your current code. After you have made the corrections already shown to you.

Paul

Srijan_Bakshi:
sir, it is now working but both are working together i want to operate from one sensor at a time..!!

Of course they are "working together" since they are both being tested at the same time.
It is not clear what you mean by "one sensor at a time". What, EXACTLY, do you want your sketch to do.

I am using it in a car parking system and I am using 2 sensors at two sides of the servo motor as the entry and exit sensor in a parking lot .So if the car comes from one side then the respective sensor should sense and rotate the servo.
This is what I want to perform.

Srijan_Bakshi:
I am using it in a car parking system and I am using 2 sensors at two sides of the servo motor as the entry and exit sensor in a parking lot .So if the car comes from one side then the respective sensor should sense and rotate the servo.

Are you saying that you want one sensor to OPEN the gate when a car approaches the gate and the other sensor to CLOSE the gate when the car has passed through the gate?