which sensor to use?

how can I tell arduino that there is one person in the room even if it stops to make sure that I keep the lights turned on? and when it leaves me off?

Two optic barriers at entrance. Depending on which one is interrupted first you know the guy is entering or leaving.

will work if the entrance can hold only one person at the time :wink:

robtillaart:
will work if the entrance can hold only one person at the time :wink:

If the door is for 2 persons you need to add 2 more sensors and place them vertically. Made something similar in university. The only problem was when a big guy came he would count as 2. However, when he would get out the counter would decrement by 2 so it didn't mess up the counting. The idea was to open/close the lights when someone was in the room.