Can't get actual output when, both input logic is high I want
When,


light=0, ir=0 then output will pin 8 high &amp; pin 12 low.
light=0, ir=1 then output will pin 8 high &amp; pin 12 high.
light=1, ir=0 then output will pin 8 low &amp; pin 12 low.
light=1, ir=1 then output will pin 8 low &amp; pin 12 low (This statement
does not work).


Please find the code &amp; suggest me, if any modification is needed.

void setup() {

    pinMode(8,OUTPUT); //logic output.
    pinMode(12,OUTPUT); //logic output.
    pinMode(2, INPUT); //value input.
    pinMode(4, INPUT); //value input.

    Serial.begin(9600);   
}


void loop() {

    int light = digitalRead(2); //value input.
    int ir = digitalRead(4); //value input.

    if (light == LOW &amp;&amp; ir == LOW)
    {

      digitalWrite(8, HIGH);
      digitalWrite(12, LOW);
      delay(2000);

    }

    if (light == LOW &amp;&amp; ir == HIGH)
    {

      digitalWrite(8, HIGH);
      digitalWrite(12, HIGH);
      delay(2000);

    }

    if (light == HIGH &amp;&amp; ir == LOW)
    {

      digitalWrite(8, LOW);
      digitalWrite(12, LOW);
      delay(2000);

    }

    if (light == HIGH &amp;&amp; ir == HIGH) //This condition does not work.
    {

      digitalWrite(8, LOW);
      digitalWrite(12, LOW);
      delay(2000);

    }

    digitalWrite(8, LOW);
    digitalWrite(12, LOW);   
    delay(2000);

}
You can simplify your requirements somewhat by splitting your inputs up.


  light=0, ir=0 then output will pin 8 high &amp; pin 12 low.
  
  light=0, ir=1 then output will pin 8 high &amp; pin 12 high.


If light is 0 then pin 8 is high. AND ir is echoed to pin 12.


  light=1, ir=0 then output will pin 8 low &amp; pin 12 low.
  
  light=1, ir=1 then output will pin 8 low &amp; pin 12 low


If light is 1 then both pins 8 and 12 are low, and you don't care what ir does, since it doesn't have any effect on the outputs.

So your structure could look more like:

if (light == 0) {
    digitalWrite(8, HIGH); // 8 will always be high with light == 0
    digitalWrite(12, ir); // echo the ir value to pin 12
} else {
    digitalWrite(8, LOW); // if light is 1 then everything
    digitalWrite(12, LOW);// is low regardless of ir.
}