# Detecting Motion behind a robot

I am building a motion following robot. It has two PIR sensors on the left and right. It has an ultrasonic sensor in the front. When either of the PIR sensors detect motion then it turns to that side.

When both the PIR sensors sense motion then I calculate the distance first( with the ultrasonic sensor, if distance <= 50 cm and > 5 cm then the robot moves forward. But it could mean that the motion is either in the front or in the back. Thus, my robot moves forward even the motion is behind it.

I need some help devising a method so that when motion is detected behind then the robot will turn back. I tried making the robot turn right when both the sensors detect motion, then it will turn towards the left(i.e. front) or right(i.e. back). But in reality this method is not so practical as it would to a lot of confusion when the intruder we are trying to detect is still in motion. Plz help. A sample sketch would help.

• PIR sensors only detect moving heat sources. That is, moving relative to the PIR sensor. If the PIR sensor is moving then everything is moving relative to it, so who knows what it will be detecting. PIR is not, IMHO. a good choice for this kind of thing. Jan 24, 2016 at 14:21
• Dont worry about that. The if statement conditions state that when only one PIR detects motion, then the robot turns towards that side. Then it again checks the outputs. Jan 24, 2016 at 15:00
• Couldn't you point the PIRs slightly to the back. So you essentially split the 360degrees into three sections. Jan 24, 2016 at 19:58
• Was the answer helpful? If so, please accept it by clicking on the "tick" icon next to the answer, and also possibly upvote it. This indicates to other users that you found the answer useful, and it also stops Stack Exchange from periodically "bumping" your question in the hope of getting an accepted answer. Thanks for your understanding and cooperation! Jan 25, 2016 at 22:57

This is a basic problem of only having two sensors. There is no way that two sensors of this simple type (some motion yes/no) can be used to work out where the motion comes from except when there is a difference between the two sensors. Anything else is, and always will be, ambiguous.

If you think of it as a circle divided in two, you have only three possible conditions:

That is, left, right or somewhere. Not ideal.

So you need more data to be able to make a decision. That means more sensors. The ideal scenario is four sensors - left, right, front and rear. That gives you many possible scenarios, including:

As you can see from that you have a full 360° idea of where the motion is. You can even know how far to the left it is by if the front or rear is also on. For instance, using sailing terminology, those 8 circles would mean (in order):

1. Motion on the left beam
2. Motion on the port bow