house automation with sensor

Hi I am doing a arduino code and using ir sensor and relay for automation. I h ave used two ir sensors.
--> it works as follow..if sensor1 is interrupted it must check sensor2 then if it is also interrupted then count is increased and relay is on
-->if sensor 2 is interrupted first and the sensor1 is next then count is dec and relay off

Please post your code even if it doesn't work- you will get more help that way.