Programming PIR Sensors to Control 360 Servo Motors

Hi guys I am a newbie to Arduino and I have built a rube goldberg machine for engineering school. It is a small replica of a vending machine that vends toy cars and pop's a balloon. I will include pics. The machine is to use an arduino uno microcontroller, a bread board, five 360 servo motors, and four PIR sensors to control it. I am having trouble detecting the triggers from the sensors and using those triggers to control the servo motors. I think if someone could help me program one sensor to control one servo motor, I could probably figure out how to apply it to the rest of the sensors and servos. The program will be an event based program with event checkers and event handlers. But first I need to be able to connect a single servo motor and PIR sensor in a circuit and have the detection of movement start and stop the motor. Thanks in advance to anybody that helps me out!

Here is my current code to just have one servo control one motor. It compiles but it doesn't work correctly.

Code: [Select]

#include <Servo.h>

Servo trackServo;
int trackPir = 2;
int val = 0;

//SENSOR Initialization CODE****************************//
//the time we give the sensor to calibrate (10-60 secs according to the datasheet) //
int calibrationTime = 30; //
//the time when the sensor outputs a low impulse //
long unsigned int lowIn; //
//the amount of milliseconds the sensor has to be low //
//before we assume all motion has stopped //
long unsigned int pause = 5000; //
boolean lockLow = true; //
boolean takeLowTime; //
//int trackSensor = 3; //the digital pin connected to the PIR sensor's output //
//SENSOR Initialization CODE****************************//

void setup() {
// put your setup code here, to run once:

pinMode (trackPir, INPUT);
//pinMode(trackServo, OUTPUT);


//give the sensor some time to calibrate
Serial.print("calibrating sensor ");
for (int i = 0; i < calibrationTime; i++) {
Serial.println(" done");
Serial.println("SENSOR ACTIVE");
Serial.println("Check Sensor State");


void loop() {
// put your main code here, to run repeatedly:

val = digitalRead(trackPir);

if (val == HIGH){

Serial.println("Motion Detected");
Serial.println("No Motion Detected");
//val = 0;

It compiles but it doesn't work correctly

What should it do ?
What does it do ?

Right now it does nothing. It should use the triggers from the sensors to control the direction of rotation, the time of rotation, and the degree of rotation of the servo motors.

No dots ?
No messages ?

What values are you seeing for val ?

; Maybe this video will help to clear up the overall purpose and function of the project:

Ok. Thanks first for taking the time. Those sensors that you posted a link to are the exact sensors I have. They have three parallel pins, and one pin sitting solitary. The Servos are 360 continuous servos. I will explain the project in detail and I hope it is not too much. I wanted to spare the readers the boredom. I'll try to attatch pics.

So as an overview, the machine functions as a grabber machine. In the first process a spinning platform, spun by a servo motor (platformServo), holding 4 cars spins and stops with one car in the pull position. The four cars are located at 0, 90. 180, and 270 degrees. This platform is hard coded to spin and does not use any sensors. A string with a magnet attached roles down a pulley-system, driven by a second servo motor (pullerServo), and pulls the car from the pull position straight up rolling along the same pulley-system. A sensor, pullerSensor, at the bottom near the platform triggers the pullerServo to reverse direction and pull the car up. As the car rises it gets above the initial track, a sensor located at the track is triggered, trackSensor, and it stops the pullerServo. A third servo (trackServo) rolls the initial track out and up under the car. After the track is up under the car the pullerServo pulls the car the remainder of the way up where 2 forks pushes the car off the magnet.The car rolls downhill along a track and enters an elevator. The elevator raises to the top floor and a third sensor, elevatorSensor, is triggered which commands a fourth servo, doorServo, to pull the elevator door open which is driven through a pulley-system. The car rolls out of the elevator onto another decline and it carries the car to a balloon. The point on the car pops the balloon and the final sensor, finishSensor, tells every other servo to reset and also commands a fifth servo, powerServo, to separate four wires (two hot and two cold wires for the power source to close the circuit) that marry to power the machine on.

I hope it's not too much to take in over a blog. Val continually gives me a 1. It's like the sensor is not working properly... :o

It's like the sensor is not working properly..

or is wired incorrectly

What happens if you substitute a switch , or a length of wire shorted to GND, for the PIR ?

What is the sensor supposed to be sensing? A PIR (Passive InfraRed) sensor sense warm bodies moving.