This is my motion tracking head using four PIRs (Passive InfraRed Sensors), an Arduino Uno board and a servo. 
It is a simple way to give the impression that the head (birdy) is actually following movement.
It is a very easy project to build but a little time consuming to make the wiring harness that connects the PIRs to the Arduino. I simply wire the PIRs positive and negative wires together and power them directly off the Arduino 5 volt circuit, plug the signal wires into the Arduino digital ports 3,4,5 and 6, plug the servo also into the 5 volt and ground ports and it's signal into the 9 port and run my program which is also fairly simple.
The program cycles through each PIR input via an array and if the PIR goes HIGH then moves the servo to that PIR's corresponding servo position. I had to add another array to track each PIR and only allow it to be used once per HIGH state or else it sometimes would jump between adjacent PIR servo positions - a definitely birdlike movement but not too desirable.
This would be a great Halloween mechanism to track movement with a head.

This is the first project I ever used with an Arduino board and I was surprised how easy it is to use. It took only minutes to install the software and run the LED Blink program. Hope to use it for more projects in the future.

The PIRs should have the shortest delay time possible. The minimum delay on this particular PIR is 2.5 seconds which is how long you would have to wait for the PIR to go LOW before it can detect new movement. Some more expensive PIRs probably are faster but 2.5 seconds is ok. Longer time PIRs makes for a more frustrating performance.
More PIRs would also make for a more realisitic movement of the head. Also, one could slow down movement between PIR positions for more realistic movement by incorporating a delay subroutine but I like the faster movement myself. With more PIRs is wouldn't be quite so jerky though.

Step 1: Make Wiring Harness for PIRs

Each PIR has a positive voltage, negative voltage and signal post. I used some old connectors I took off some dead servos and also some from some dead lipo batteries. See closup photo of connector. The lipo battery connectors have 4 connections and I just use the left or right three which fortunately fit the PIR connector pretty closely.
Solder longer  wires to the three left or right wires of the connector. Do this for each PIR. It is important to use somekind of connector for the PIR as soldering directly to the PIR may kill it (I did that a couple of times and learned my lesson).
I also soldered a breade board connecting wire to the end of the positive and negative wire bunches and to the end of each signal wire as these are easier to push into the Arduino and bread board holes.

As per the crudely drawn schematic, solder all the positive PIR wire ends together, solder all the negative wire ends together. These will be connected to the Arduino 5 volt and grnd ports.

Step 2: Make PIR Holder or Mount

You have to have something to hold the PIRs in a semi-circle and I have found the EPP foam is easy to work with and I have a bunch of it that I use to build RC airplanes. Use whatever you have.
Cut a hole to hold the PIR. EPP is flexible so just a rough cut hole is sufficient. The PIR can be hotglued into the foam but mine just sit in there held in by friction.
You also need to cut some square pieces to serve as separators between the PIR or else they will overlap each other and cause fluctuating servo movement. You want each PIR to have it's own range of coverage.

Step 3: Connect Wiring Harness to Arduino

I used a white breadboard to connect the Arduino 5 volt and ground ports to the PIR wiring harness and to the servo.
Connect each PIR signal wire to Arduino digital ports 3,4 5, and 6.
Connect the servo signal wire to Arduino digital port 9.

The servo is sitting under the bird mounted in a cardboard tea container. It has 3 wires also, a positive, negative and signal wire.

Step 4: Upload Program

Here is my program. Pretty self explanatory. I assign each PIR pin to an array and in my main loop cycle through the array checking each PIR for a HIGH state. If it goes HIGH then move the servo to the corresponding PIR servo position.
I originally set it up for 5 PIRs but one of the wiring harnesses was bad so rather than tear it apart and fix it I went with just 4 PIRs.

The program does two other things. If the a PIR is HIGH and the servo is already at that PIRs corresponding position, dont move it.
Also, I use another array to track if the PIR has been used since it went HIGH. I only allow it to be used once for each HIGH state. If you don't do that you get added movement between adjacent PIRs that is not necessary.

I just turn on the LED whenever a PIR is HIGH so I can tell by looking at the Arduino if there is some activity in the PIRs.

#include <Servo.h>
// author: jim demello feb 2014 //
boolean pirStatus;
Servo servo1;
int servangle = 0; // servo angle variable
int pirNo[] = {3,4,5,6,7};          // pir pin numbers
int pirPrevLow[] = {1,1,1,1,1};     // previously low flag set to true
int pirPrevUsed[]  = {0,0,0,0,0};     // has pir been on used before going low
int pirPos[] = {10,60,100,140,170}; // positions for servo (0-180)
int curPosPir = 0;
int pirPin = 3;  
int ledPin = 13;

void setup(){
  for(int i=0;i<4;i++){
  pinMode(pirNo[i], INPUT);
  pinMode(ledPin, OUTPUT);
  delay(10000); // calibrate for about 10 seconds
  //  servo1.write(90); // put servo at center to begin
//Main LOOP
void loop(){
  for(int j=0;j<4;j++){ // for each PIR
     pirStatus = digitalRead(pirPin);
     if (pirStatus == HIGH) {
          digitalWrite(ledPin, HIGH);   //the led visualizes the sensors output pin state
          if(pirPrevLow[j])    { 
                if (curPosPir != pirPin && pirPrevUsed[j] == 0) { // if high PIR is different than current position PIR then move to new position
                   curPosPir = pirPin; // keep current PIR
                   pirPrevUsed[j] = 1;
          pirPrevLow[j] = 0; // pir is now not low
      else {
              digitalWrite(ledPin, LOW);  //the led visualizes the sensors output pin state
              pirPrevLow[j] = 1;   // pir is now low
              pirPrevUsed[j] = 0;
    } // end j number of pirs loop
  }// end infinite loop

<p>Can I get a little more in depth wiring sechmatic or picture of the wiring and stuff like that?</p>
<p>Sorry but this is all there is. I don't have this circuit anymore; left all that stuff behind at my last school. If you have a particular question I may be able to help though.</p>
Maybe where you put the wires for the PIRs and did any of this require soddering?<br>
<p>Yes it requires soldering. You need to look at the schematic and it will explain where the wires go. If that is too difficult then you probably need to begin with a simpler project. This project does require some ability to understand basic electronics and programming.</p>
<p>Hi, what would happen if the servo rotates the whole PIRs instead of the bird? will it get autocentered?</p>
<p>Thats an interesting idea but I have no idea what would happen. Unfortunately I dont have this project anymore to test it out.</p>
<p>hi, this post is extremely helpful. i'm looking to create a tracking turret for a predator costume for a friend and i dont know much about this kind of system. how would you recommend doing this so the turret follows the heads movement rather than the other people around? thank you</p>
<p>Sorry to reply so late. I think you would have to use a sonar module so you could find the nearest object to you. Dont think you could do it with PIRs. Just guessing though.</p>
<p>this is amazing thank you for posting this it is a very big help for a school project. thanks again</p>
<p>Hi.. </p><p>awesome and nice project !!</p><p>but how if want to reduce speed servo if human detected?</p><p>can you give example code? </p>
No I don't have this project around anymore. Sorry.
up to what distance can it detect motion.??
A couple of meters.
<p>Hey! I followed your tutorial except i used my laptop as the power source. The thing is there seems to be a bigger delay in my device than for yours. do you think its the sensors? Where did you get your pir sensors from?</p>
Haha super cool, im building a security system for my workbench that involves a spotlight that tracks. Your project is a pretty cool way to go about tracking.
Thanks. Ive seen a commercial one that tracks with two pirs, not sure how well it works and kind of expensive at 150.00. Good luck hope you post instructable.
<p>Hi. Your project sounds neat. Without actually building it, Im not sure how I would do it either. Just a couple of thoughts. One, just leave the array of four as it is but put in if-condition, if it is the 4th one active, move head down else keep head up. Also relocate your 4th PIR to where you want it. This is the simplest way I can think of but not very sophisticated.</p>
<p>Awesome !! I'm making a robo monkey -its head will follow motion via this 'structable! I dont suppose you know how to use 2 servos with PIRs each would ya? I want the head to turn L /R using 3 PIRs L/C/R and one servo as in your project but, a second servo mounted on that for Up and Down tracking..ie a + pattern of PIRs L / R /Center- Up / Down..So 3 PIRs for horizontal and 2 PIRs for vertical .make any sense?...I tried hacking up your sketch but I am VERY new to this and got lost in the mess I made of it.</p>

About This Instructable




Bio: I am an American teaching English at Shangluo University, Shaanxi. I like making machines that do interesting but fairly useless things - I call them Quixotic ... More »
More by JimRD:Arduino Controlled Morse Code Key and Transmitter Magnetic Levitating Globe Tear-apart and Fix Morse Code Key (and Sounder) Made From Steak-knife and Multi-tester 
Add instructable to: