Things used in this project

Hardware components:
A000066 iso both
Arduino UNO & Genuino UNO
×1
Panasonic eca2am101
Capacitor 100 µF
×1
09590 01
LED (generic)
×5
13285 01
PIR Motion Sensor (generic)
×5
Resistor, 220 ohm
×5
Servo (generic)
×1

Schematics

Circuit Diagram
Schematics
Base/Stand Construction - Part 1
Base/Stand Construction - Part 2

Code

The Main CodeArduino
The PIR Sensors will calibrate for 15 seconds after powering up the Arduino. It is recommended that you leave the room during this process so that the sensors get a true image of the room without any motion.
/*************************************************
*** The Motion Following Motorized Camera Base ***
***               by Lindsay Fox               ***
*************************************************/

// Servor motor
#include <Servo.h>
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 < 15; c++){ // calibrate PIR sensors for 15 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

Credits

Me
Lindsay Fox

I'm an artist who loves to dabble in just about every hobby you can imagine. My biggest challenge is finding the time to do it all!

Replications

wards

Replica

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

3D-Printed Prank Vibrating Cup
Easy
  • 1,065
  • 13

Full instructions

The instant your prankee lifts up this 3D-printed cup it starts violently vibrating! The electronics separate from the cup for easy washing.

The Magic Display With Arduino - The Mind Reader
Easy
  • 1,136
  • 5

Full instructions

The Magic Display With Arduino can figure out with a few clues what is your choose on a card with 64 options of numbers, letters or symbols.

Very First Hands On Arduino - Voice Activated LED
Easy
  • 451
  • 6

Full instructions

Use voice command to turn LED on or off.

Get Connected! WiFi Registration Using AP Mode!
Easy
  • 1,130
  • 15

Full instructions

Stop reflashing your devices everytime the WiFi password changes! Learn how to use anduinoWiFi and AP mode to initiate WiFi registration!

Car Blinker
Easy
  • 164
  • 3

Protip

Blink for Vehicles, such as bikes and skates. Easy.

The Soldering Iron Controller for Hakko T12 Tips
Easy
  • 8,217
  • 26

Full instructions

Per-tip calibration and high-frequency temperature check by Timer1.

ProjectsCommunitiesContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback