Infrared Emitting

Electronics project help?
I am trying to build an automatic room light controller that will turn on a lamp when a person enters a room and maintains it in the on state as long as the room is occupied. once the room is empty, the lamp will switch off. I intend to use a PIC for this project, together with an infrared emitting diode and phototransistor for detecting entry and exit. But my major problem is making the circuit direction sensitive. How can I differentiate between entry and exit? I would really appreciate any help I can get. Thanks
Your idea has been existed long long time ago,a product called motion detection light using in the backyard or stair. $10 a piece sold in most warehouse store. You may buy one , open it and study it. It has a build in infra red transmitter and receiver mount together as a piece of parts, you can control the angle by adjust the window direction or narrow the beam with small size of openning. It also has a delay timer to control the time when motion is no more detected.
Tagged as:
infrared emitting,
infrared emitting diode,
infrared emitting diode circuit,
infrared emitting diode datasheet,
infrared emitting diode pdf,
infrared emitting diode schematic,
infrared emitting diode wikipedia,
infrared emitting led,
infrared emitting led lights,
infrared emitting phosphors