Recognizing the direction of a movement

Hey,
I'm new in the world of Arduino :slight_smile:

My problem is I have to do a skilled work for school, in which I have to do something what is connected to Arduino and Smarthomes.

I decided to build a lamp that turns off if somebody enters the room and turns off if he lefts the room. There are some more functions but they are not important for this problem.

The Problem is, that I do not just need to recognize if there is a movement next to the door, i have to know in whixch direction it is going because the light should just turn of if u leave the room and not if another person enters.

My Idea was to build two light barriers. If the first recognizes a movement it waits for a second if the other one recognizes it too. Depending on which barrier recognizes this movement first, i can see if the person is entering the romm or if it is lefting the room.

But I dont really know how to build light barriers ... there are so much possibilities like laser etc. woukd be great if sb could help me.

:slight_smile:

Place two IR pairs and number them 1 and 2. Try to get time instances when the IR receivers do not get light from transmitter.
Consider the instances of time x1 and x2.
X1-x2 positive means you can consider over direction movement and if the value of negative then the direction is opposite.