Please help me for logical conditions.

I try to program a Car security system using an RFID and IR Sensor and the output is a servo motor
this is my codes

void loop()
{
if((digitalRead(IR) == HIGH) && (digitalRead(RFID) == HIGH))
{
myServo.write(90);
}
else if(digitalRead(IR) == LOW)
{
myServo.write(0);
}
}

it's works fine
but my IR sensor is a LOW logic output and when I change the codes like this

void loop()
{
if((digitalRead(IR) == LOW) && (digitalRead(RFID) == HIGH))
{
myServo.write(90);
}
else if(digitalRead(IR) == HIGH)
{
myServo.write(0);
}
}

my servo is not functioning well.
Can someone teach the right logical condition for this
thanks in advance.

it's works fine

Why change it?

Pete

lordpopo09:
it's works fine
but my IR sensor is a LOW logic output and when I change the codes like this

void loop()

{
 if((digitalRead(IR) == LOW) && (digitalRead(RFID) == HIGH))
 {
   myServo.write(90);
 }
 else if(digitalRead(IR) == HIGH)
 {
   myServo.write(0);
 }
}

The first thing is to find out what is causing the problem
Change the code a little so you can print the values of the variables and then you can see what is happening

void loop()
{
  irVal = digitalRead(IR);
  rfidVal = digitalRead(RFID);
  Serial.print("IR ");
  Serial.print(irVal);
  Serial.print("   RFID ");
  Serial.println(rfidVal);
  if(irVal == LOW) && (rfidVal == HIGH))
  {
    myServo.write(90);
  }
  else if(irVal == HIGH)
  {
    myServo.write(0);
  }
}

It may also be wise to split your IF clause into two to make the logic more obvious

if(irVal == LOW) 
  {
     if (rfidVal == HIGH) {
        myServo.write(90);
     }
  }
  else 
  {
    myServo.write(0);
  }

...R

Getting data from an IR sensor generally requires more than knowing if the pin is HIGH or LOW at some arbitrary point in time.

What kind of RFID reader outputs a HIGH or LOW on a digital pin?