jrdoner:
You don't post your code, showing how you read the motion sensors, so it is not possible to help you there.
As to wire lengths, you need good ol' Ohm's law, E = IR (voltage = current time resistance). As your wire gets longer, it contains more resistance. If your sensor uses only a very small current, you won't have much voltage drop. If you do have too much voltage drop, use a larger gauge of wire, which decreases the resistance per foot.
Hi sorry still kinda new to this here is the code I got called PIRsense from this arduino website at Arduino Playground - HomePage. I used it to read motion from the serial port into a program I was making in C++ in Visual Studio to turn pictures from red to green but it was quite complicated the loop so I opted to make a physical version instead. Here is the code I used, when I added a PIR sensor I assigned it to a PIN and copied to them in each section to match the new PIN name etc. I did the same with the LED. However only the first LED and motion sensor I hooked up was working and cannot understand why:
/*
* //////////////////////////////////////////////////
* //making sense of the Parallax PIR sensor's output
* //////////////////////////////////////////////////
*
* Switches a LED according to the state of the sensors output pin.
* Determines the beginning and end of continuous motion sequences.
*
* @author: Kristian Gohlke / krigoo (_) gmail (_) com / http://krx.at
* @date: 3. September 2006
*
* kr1 (cleft) 2006
* released under a creative commons "Attribution-NonCommercial-ShareAlike 2.0" license
* http://creativecommons.org/licenses/by-nc-sa/2.0/de/
*
*
* The Parallax PIR Sensor is an easy to use digital infrared motion sensor module.
* (http://www.parallax.com/detail.asp?product_id=555-28027)
*
* The sensor's output pin goes to HIGH if motion is present.
* However, even if motion is present it goes to LOW from time to time,
* which might give the impression no motion is present.
* This program deals with this issue by ignoring LOW-phases shorter than a given time,
* assuming continuous motion is present during these phases.
*
*/
/////////////////////////////
//VARS
//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 pirPin = 3; //the digital pin connected to the PIR sensor's output
int ledPin = 13;
/////////////////////////////
//SETUP
void setup(){
Serial.begin(9600);
pinMode(pirPin, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(pirPin, LOW);
//give the sensor some time to calibrate
Serial.print("calibrating sensor ");
for(int i = 0; i < calibrationTime; i++){
Serial.print(".");
delay(1000);
}
Serial.println(" done");
Serial.println("SENSOR ACTIVE");
delay(50);
}
////////////////////////////
//LOOP
void loop(){
if(digitalRead(pirPin) == HIGH){
digitalWrite(ledPin, HIGH); //the led visualizes the sensors output pin state
if(lockLow){
//makes sure we wait for a transition to LOW before any further output is made:
lockLow = false;
Serial.println("---");
Serial.print("motion detected at ");
Serial.print(millis()/1000);
Serial.println(" sec");
delay(50);
}
takeLowTime = true;
}
if(digitalRead(pirPin) == LOW){
digitalWrite(ledPin, LOW); //the led visualizes the sensors output pin state
if(takeLowTime){
lowIn = millis(); //save the time of the transition from high to LOW
takeLowTime = false; //make sure this is only done at the start of a LOW phase
}
//if the sensor is low for more than the given pause,
//we assume that no more motion is going to happen
if(!lockLow && millis() - lowIn > pause){
//makes sure this block of code is only executed again after
//a new motion sequence has been detected
lockLow = true;
Serial.print("motion ended at "); //output
Serial.print((millis() - pause)/1000);
Serial.println(" sec");
delay(50);
}
}
}
I do like Washburns very simplified version of this kind of system which was what I was going for in the code so thanks very much I will give it a try and let you know tomorrow if I can get it working or not.
I remember Ohms law in school but am having trouble applying it to my circuit as I am confused about how much resistance each component has, how much current it needs and how it should be wired etc. Here is an image of the components I have to make this work:


Three 220 ohm resistors with 5% tolerance (For the LEDs)
3 PIR Motion Sensors
3 LED's
Arduino Uno
I was wondering how these would be wired together all 3 motions sensors and 3 corresponding LEDs to make the circuit complete? If I can build the casing and unit from Perspex and wood etc and get it working I will post the project on here for all to try and enjoy if I can do it. Am just heading to bed and will try wiring it up tomorrow and testing the code thanks guys.
Henry
CWashburn:
The term 'motion sensor' is very loose. Do you mean a PIR motion sensor? If so, you could do something like this:
const int led1 = 2;// change these to the pins you want
const int led2 = 3;
const int pir1 = 4;
const int pir2 = 5;
void setup(){
pinMode(led1, OUTPUT); // declare leds as outputs
pinMode(led2, OUTPUT);
pinMode(pir1, INPUT); // declare sensors as inputs
pinMode(pir2, INPUT);
digitalWrite(led1, LOW); // turn leds off
digitalWrite(led2, LOW);
digitalWrite(pir1, LOW); // disable input pullups
digitalWrite(pir2, LOW);
}
void loop(){
if(digitalRead(pir1) == 1) // if pir1 is activated
digitalWrite(led1, HIGH); // turn led1 on
else
digitalWrite(led2, LOW); //otherwise, turn led1 off
if(digitalRead(pir2) == 1) // if pir2 is activated
digitalWrite(led2, HIGH); // turn led2 on
else
digitalWrite(led2, LOW); //otherwise, turn led2 off
}
This is definitely the kinda simple code I am looking for Washburn thanks. Just hope to get the wiring sorted so I can try it tomorrow as I have no idea about electronic circuits to be honest.