Introduction: Pointerbot
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
*2 Breadboards
*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 2: Breadboard Schematics and Setup
The breadboard setup and wiring is as you can see here. First get a power rail set up using the 5v and the ground pin on the Arduino to the larger breadboard. Set a cross power rail to the other side of the breadboard for the PIR sensors. Set the PIR sensors input wire to pins 2 through 6 and the input and output power wires for the PIR sensors on the bottom end of the breadboard. Set the leds anywhere on the breadboard, however make sure they are connected to input pins 9-13 and have a connection to the power rail. These led's are not technically used in the actual operation of the Pointerbot, but are instead used as troubleshooters during the testing phase of the project(they can be removed after you are sure the PIR sensors are working). Once your PIR sensors and leds are plugged in, get a second breadboard, which can be significantly smaller if you need.On the second breadboard is going to be the connection to the servo motor. Which is going to need a resistor on the power railed wires which connect the two breadboards and the servo motor and a third one next to the power rail which connects to the Arduino through the breadboard or directly, if you have the right type of wire.
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
Serial.println("PIR Sensors Ready");
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
PIRstatus = digitalRead(currentPIRpin);
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).