This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com). Pointerbot is a motion sensing base that uses PIR (passive infrared sensors) to sense motion around the bot then uses a servo motor to point at where it senses the motion. This can be used for a base in a motion following security camera, or even just a cat toy, depending on the base you put on the servo motor.

## Step 1: Materials

For this project you'll need

*An Arduino Uno

*Several male to female and male to male wires.

*A servo motor

*5 PIR motion sensors

*Leds, (although not neccesary)

*Resistors

*A case to hold all the materials that you don't want visible (personally I used a DC-47P DC Series Heavy Duty enclosure, and some 3d printed parts, but you could use anything as long as it contains the parts you want it to and keeps the PIR sensors and the motor steady.

*A power source.

*A case to hold PIR sensors and the server motor steady( I literally used force and hot glue so use whatever you feel will work.

*Finally and most importantly, find what you want to put on the servo motor, whether it be a camera for security, a laser for a cat toy or something else.

## Step 3: Code Involved in the Project

// Servor motor

#include Servo camServo; // name the servo motor controlling the camera base

int currentPIRposition = 0; // set current angle of servo

// LED status lights int LEDpin[] = {9,10,11,12,13}; // LED pin numbers

int currentLEDpin = 9; // the current LED pin; begin with the first in the sequence above

// PIR sensors int PIRpin[] = {2,3,4,5,6}; // PIR pin numbers

int currentPIRpin = 2; // the current PIR pin; begin with the first in the sequence above

int PIRprevState[] = {1,1,1,1,1}; // the previous state of the PIR (0 = LOW, 1 = HIGH)

int PIRposition[] = {157,117.75,78.5,39.25,0}; // assign angles for servo motor (0-157 distributed equally between 5 PIR sensors)

boolean PIRstatus; // Set status of PIR sensor as either true or false

///// SETUP //////////////////////////////////////

void setup()

{ Serial.begin(9600);

camServo.attach(7); // assign servo pin

for (int p = 0; p < 5; p++) { // set all PIR sensors as INPUTS pinMode(PIRpin[p], INPUT); } // end 'p' for

for (int l = 0; l < 5; l++) { // set all LEDs as OUTPUTS pinMode(LEDpin[l], OUTPUT); } // end 'l' for

/////// CALIBRATE PIR SENSORS /////// Serial.print("Calibrating PIR Sensors ");

for(int c = 0; c < 60; c++){ // calibrate PIR sensors for 60 seconds (change from 10-60 sec depending on your sensors)

Serial.print(".");

delay(1000); // wait 1 second } // end calibration for

camServo.write(78.5); // move the servo to the center position to begin } // end setup

///// MAIN LOOP //////////////////////////////////

void loop()

{ for (int PIR = 0; PIR < 5; PIR++){ // start this loop for each PIR sensor
currentPIRpin = PIRpin[PIR]; // set current PIR pin to current number in 'for' loop

currentLEDpin=LEDpin[PIR]; // set current LED pin to current number in 'for' loop

if (PIRstatus == HIGH) { // if motion is detected on current PIR sensor

digitalWrite(currentLEDpin, HIGH); // turn corresponding LED on

if(PIRprevState[PIR] == 0)

{ // if PIR sensor's previous state is LOW

if (currentPIRposition != currentPIRpin && PIRprevState[PIR] == 0)

{ // if high PIR is different than current position PIR then move to new position

camServo.write(PIRposition[PIR]);

Serial.print("Current angle : ");

Serial.println(PIRposition[PIR]);

delay(50);

currentPIRposition = currentPIRpin; // reset current PIR position to active [PIR] pin

PIRprevState[PIR] = 1; // set previous PIR state to HIGH }

PIRprevState[PIR] = 1; // set previous PIR state to HIGH if the current position is the same as the current PIR pin }

// end PIRprevState if }

// end PIRstatus if else {

digitalWrite(currentLEDpin, LOW);

//the led visualizes the sensors output pin state PIRprevState[PIR] = 0;

// set previous PIR state to LOW } // end else } // end [PIR] for loop } // end main loop

## Step 4: 3D Printed Parts

If you are going to 3D print parts here's what you'll need to print. You will need to print a pentagon with five holes capable of holding your PIR sensors. I personally printed my pentagon in 5 separate parts and then assembled them together, but if you want to do it as one whole pentagon that would work too, just make sure to include room for the servo motor either inside the pentagon, or outside, as I did with my project. If you are setting the servo motor outside the pentagon make a solid base to cover the top of the pentagon and the wiring of the motor and sensors, while having a small hole to let the servo motors 3 wires slip through. Make sure to measure the size of your PIR sensors and the servo motor so your assembly will fit. Also make sure your hole for the PIR sensor and servo motor fit and measure them before designing the 3D parts. Finally you can design the holder for whatever you want to put on top of the servo motor however you wish(within weigh and balance necessities, which would depend on the motor your using).

<p>Very cool! Thanks for sharing! </p>