<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Arduino &#8211; (Very) Basic motion tracking with 2 PIR sensors</title>
	<atom:link href="http://luckylarry.co.uk/arduino-projects/arduino-very-basic-motion-tracking-with-2-pir-sensors/feed/" rel="self" type="application/rss+xml" />
	<link>http://luckylarry.co.uk/arduino-projects/arduino-very-basic-motion-tracking-with-2-pir-sensors/</link>
	<description>Arduino, mainly Arduino projects, tutorials... and a few other things</description>
	<lastBuildDate>Tue, 07 Sep 2010 18:55:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: larry</title>
		<link>http://luckylarry.co.uk/arduino-projects/arduino-very-basic-motion-tracking-with-2-pir-sensors/comment-page-1/#comment-1574</link>
		<dc:creator>larry</dc:creator>
		<pubDate>Mon, 12 Apr 2010 19:54:42 +0000</pubDate>
		<guid isPermaLink="false">http://luckylarry.co.uk/?p=298#comment-1574</guid>
		<description>Hey John I got a 3rd sensor so I&#039;m just wiring this up now and I&#039;ll write it up - hopefully it should help you out.</description>
		<content:encoded><![CDATA[<p>Hey John I got a 3rd sensor so I&#8217;m just wiring this up now and I&#8217;ll write it up &#8211; hopefully it should help you out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: larry</title>
		<link>http://luckylarry.co.uk/arduino-projects/arduino-very-basic-motion-tracking-with-2-pir-sensors/comment-page-1/#comment-1548</link>
		<dc:creator>larry</dc:creator>
		<pubDate>Thu, 08 Apr 2010 15:43:57 +0000</pubDate>
		<guid isPermaLink="false">http://luckylarry.co.uk/?p=298#comment-1548</guid>
		<description>Have you got a 3rd PIR yet? - I&#039;ll get me one and I&#039;ll create a new post and how-to for you to follow. :)</description>
		<content:encoded><![CDATA[<p>Have you got a 3rd PIR yet? &#8211; I&#8217;ll get me one and I&#8217;ll create a new post and how-to for you to follow. <img src='http://luckylarry.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: john</title>
		<link>http://luckylarry.co.uk/arduino-projects/arduino-very-basic-motion-tracking-with-2-pir-sensors/comment-page-1/#comment-1508</link>
		<dc:creator>john</dc:creator>
		<pubDate>Fri, 02 Apr 2010 17:57:28 +0000</pubDate>
		<guid isPermaLink="false">http://luckylarry.co.uk/?p=298#comment-1508</guid>
		<description>hey, i got my PIR sensors but only 2 came so i will go to the store later but i used your sketch and when i turned my arduino on it loads for a second and both LEDs turn on and the servo tries to move help me!!!</description>
		<content:encoded><![CDATA[<p>hey, i got my PIR sensors but only 2 came so i will go to the store later but i used your sketch and when i turned my arduino on it loads for a second and both LEDs turn on and the servo tries to move help me!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: larry</title>
		<link>http://luckylarry.co.uk/arduino-projects/arduino-very-basic-motion-tracking-with-2-pir-sensors/comment-page-1/#comment-1493</link>
		<dc:creator>larry</dc:creator>
		<pubDate>Tue, 30 Mar 2010 09:17:17 +0000</pubDate>
		<guid isPermaLink="false">http://luckylarry.co.uk/?p=298#comment-1493</guid>
		<description>Ah no my sketch will only do 3 positions left, front or right - try this code below (adding in the servos etc..) and in the meantime I&#039;ll get another PIR.
/*
This code below will check and do something if any sensor is triggered.
If more than one sensor is triggered then the code will still execute and
potentially cause conflicts e.g. the servo wants to turn both left and right!
*/
if (digitalRead(pinPIRright) == HIGH) {
    // do stuff when right
}
if (digitalRead(pinPIRleft) == HIGH) {
   // do stuff when left
}
if (digitalRead(pinPIRfront) == HIGH) &amp;&amp; (digitalRead(pinPIRright) == HIGH)) {
   // do stuff when front and right
}
if (digitalRead(pinPIRfront) == HIGH) &amp;&amp; (digitalRead(pinPIRleft) == HIGH)) {
   // do stuff when front and left
}
if (digitalRead(pinPIRfront) == HIGH) {
   // do stuff when front
}
/*
Better way is to use an &#039;else&#039; clause so that the events are specifically controlled.
This way we can have a designated single result/state so there will be no conflict.
This way should also ignore any other combinations we don&#039;t want e.g left and right
*/
if (digitalRead(pinPIRright) == HIGH) {
   // do stuff when right
} else {
	if (digitalRead(pinPIRleft) == HIGH) {
 	  // do stuff when left
	} else {
		if (digitalRead(pinPIRfront) == HIGH) &amp;&amp; (digitalRead(pinPIRright) == HIGH)) {
 		  // do stuff when front and right
		} else {
			if (digitalRead(pinPIRfront) == HIGH) &amp;&amp; (digitalRead(pinPIRleft) == HIGH)) {
			   // do stuff when front and left
			} else{
				if (digitalRead(pinPIRfront) == HIGH) {
				   // do stuff when front
				}
			}
		}
	}
}</description>
		<content:encoded><![CDATA[<p>Ah no my sketch will only do 3 positions left, front or right &#8211; try this code below (adding in the servos etc..) and in the meantime I&#8217;ll get another PIR.</p>
<p>/*</p>
<p>This code below will check and do something if any sensor is triggered.<br />
If more than one sensor is triggered then the code will still execute and<br />
potentially cause conflicts e.g. the servo wants to turn both left and right!</p>
<p>*/</p>
<p>if (digitalRead(pinPIRright) == HIGH) {<br />
    // do stuff when right<br />
}</p>
<p>if (digitalRead(pinPIRleft) == HIGH) {<br />
   // do stuff when left<br />
}</p>
<p>if (digitalRead(pinPIRfront) == HIGH) &amp;&amp; (digitalRead(pinPIRright) == HIGH)) {<br />
   // do stuff when front and right<br />
}</p>
<p>if (digitalRead(pinPIRfront) == HIGH) &amp;&amp; (digitalRead(pinPIRleft) == HIGH)) {<br />
   // do stuff when front and left<br />
}</p>
<p>if (digitalRead(pinPIRfront) == HIGH) {<br />
   // do stuff when front<br />
}</p>
<p>/*</p>
<p>Better way is to use an &#8216;else&#8217; clause so that the events are specifically controlled.<br />
This way we can have a designated single result/state so there will be no conflict.<br />
This way should also ignore any other combinations we don&#8217;t want e.g left and right</p>
<p>*/</p>
<p>if (digitalRead(pinPIRright) == HIGH) {<br />
   // do stuff when right<br />
} else {</p>
<p>	if (digitalRead(pinPIRleft) == HIGH) {<br />
 	  // do stuff when left<br />
	} else {</p>
<p>		if (digitalRead(pinPIRfront) == HIGH) &amp;&amp; (digitalRead(pinPIRright) == HIGH)) {<br />
 		  // do stuff when front and right<br />
		} else {</p>
<p>			if (digitalRead(pinPIRfront) == HIGH) &amp;&amp; (digitalRead(pinPIRleft) == HIGH)) {<br />
			   // do stuff when front and left<br />
			} else{</p>
<p>				if (digitalRead(pinPIRfront) == HIGH) {<br />
				   // do stuff when front<br />
				}<br />
			}<br />
		}<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://luckylarry.co.uk/arduino-projects/arduino-very-basic-motion-tracking-with-2-pir-sensors/comment-page-1/#comment-1489</link>
		<dc:creator>John</dc:creator>
		<pubDate>Tue, 30 Mar 2010 04:48:13 +0000</pubDate>
		<guid isPermaLink="false">http://luckylarry.co.uk/?p=298#comment-1489</guid>
		<description>I&#039;m trying to get a system like this  ,
left.                       //turning left
      Left,front.           //between left and front
                    Front.   // 90 deg. Only when front is only PIR on
      Right,front.         //between right and front
right.                    //turning right
,so there is &quot;four positions&quot; will the sketch I have work?
Thanks so much for your help I&#039;m very thankful :)</description>
		<content:encoded><![CDATA[<p>I&#8217;m trying to get a system like this  ,</p>
<p>left.                       //turning left<br />
      Left,front.           //between left and front<br />
                    Front.   // 90 deg. Only when front is only PIR on<br />
      Right,front.         //between right and front<br />
right.                    //turning right<br />
,so there is &#8220;four positions&#8221; will the sketch I have work?<br />
Thanks so much for your help I&#8217;m very thankful <img src='http://luckylarry.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: larry</title>
		<link>http://luckylarry.co.uk/arduino-projects/arduino-very-basic-motion-tracking-with-2-pir-sensors/comment-page-1/#comment-1486</link>
		<dc:creator>larry</dc:creator>
		<pubDate>Mon, 29 Mar 2010 18:17:21 +0000</pubDate>
		<guid isPermaLink="false">http://luckylarry.co.uk/?p=298#comment-1486</guid>
		<description>OK, so you want to move the 3 sensors depending on if movement is detected so it follows motion, panning a camera etc..
If I&#039;ve got that correct (apologies if I&#039;m wrong) then first of all you&#039;ll need to first check that the servo moves left and right depending on the sensor ensuring that motion is only detected on one side.
It depends on how your circuit is configured of course so you may want to change this around slightly, also a typical servo has 180 degrees of movement, so I always calculate that range so I know exactly where its meant to be.
The code below should do left or right and stop if the front is triggered:
if (digitalRead(pinPIRfront) == LOW)) {
// providing the front PIR is not detecting then we can look at left and right.
  if (digitalRead(pinPIRleft) == LOW) {
  // double check nothing is detected on the left
    if ((pos = 1) &amp;&amp; (digitalRead(pinPIRleft) == HIGH)) {
      pos -= 1;
      myservo.write(pos);
      delay(15);
    }
  }
} // else if the front is detecting we can do other stuff now.
So if thats working correctly, you should see your servo turn left on the left sensor etc... I do a check first to see if the right sensor is not detecting motion - but this was originally because I had 2 sensors (I still do!) also it safegaurds against a double positive result - if both trigger then what?
Hope that helps you out - otherwise I&#039;ll get another PIR and buid the circuit up myself :)</description>
		<content:encoded><![CDATA[<p>OK, so you want to move the 3 sensors depending on if movement is detected so it follows motion, panning a camera etc..</p>
<p>If I&#8217;ve got that correct (apologies if I&#8217;m wrong) then first of all you&#8217;ll need to first check that the servo moves left and right depending on the sensor ensuring that motion is only detected on one side.</p>
<p>It depends on how your circuit is configured of course so you may want to change this around slightly, also a typical servo has 180 degrees of movement, so I always calculate that range so I know exactly where its meant to be.</p>
<p>The code below should do left or right and stop if the front is triggered:</p>
<p>if (digitalRead(pinPIRfront) == LOW)) {<br />
// providing the front PIR is not detecting then we can look at left and right.<br />
  if (digitalRead(pinPIRleft) == LOW) {<br />
  // double check nothing is detected on the left<br />
    if ((pos = 1) &amp;&amp; (digitalRead(pinPIRleft) == HIGH)) {<br />
      pos -= 1;<br />
      myservo.write(pos);<br />
      delay(15);<br />
    }<br />
  }<br />
} // else if the front is detecting we can do other stuff now.</p>
<p>So if thats working correctly, you should see your servo turn left on the left sensor etc&#8230; I do a check first to see if the right sensor is not detecting motion &#8211; but this was originally because I had 2 sensors (I still do!) also it safegaurds against a double positive result &#8211; if both trigger then what?</p>
<p>Hope that helps you out &#8211; otherwise I&#8217;ll get another PIR and buid the circuit up myself <img src='http://luckylarry.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: john</title>
		<link>http://luckylarry.co.uk/arduino-projects/arduino-very-basic-motion-tracking-with-2-pir-sensors/comment-page-1/#comment-1485</link>
		<dc:creator>john</dc:creator>
		<pubDate>Mon, 29 Mar 2010 16:27:43 +0000</pubDate>
		<guid isPermaLink="false">http://luckylarry.co.uk/?p=298#comment-1485</guid>
		<description>so i have retyped almost all of the sketch and here is what i got,
#include
Servo myservo;
int pos = 0;
int pinPIRleft = 4;
int pinLEDleft = 8;
int pinPIRright = 2;
int pinLEDright = 10;
int pinPIRfront = 5;
int pinLEDfront = 7;
void setup() {
  pinMode(pinLEDleft, OUTPUT);
  pinMode(pinLEDright, OUTPUT);
  pinMode(pinLEDfront, OUTPUT);
  pinMode(pinPIRleft, INPUT);
  pinMode(pinPIRright, INPUT);
  pinMode(pinPIRfront, INPUT);
  myservo.attach(9);
}
void loop() {
  if (digitalRead(pinPIRleft) == LOW) {
    digitalWrite(pinLEDleft, HIGH);
    if ((pos = 1) &amp;&amp; (digitalRead(pinPIRleft) == HIGH)) {
      pos -= 1;
      myservo.write(pos);
      delay(15);
    }
  } else {
    digitalWrite(pinLEDright, LOW);
  }
  if ((digitalRead(pinPIRleft) == LOW) &amp;&amp; (digitalRead(pinPIRright) == LOW)) {
  }
}
I&#039;m stuck on the servo moving part, I want to make it so when the front PIR is on the sensor stops in its place until PIR left or right is the only one on please help me wright the last bit</description>
		<content:encoded><![CDATA[<p>so i have retyped almost all of the sketch and here is what i got,</p>
<p>#include<br />
Servo myservo;<br />
int pos = 0;<br />
int pinPIRleft = 4;<br />
int pinLEDleft = 8;<br />
int pinPIRright = 2;<br />
int pinLEDright = 10;<br />
int pinPIRfront = 5;<br />
int pinLEDfront = 7;</p>
<p>void setup() {<br />
  pinMode(pinLEDleft, OUTPUT);<br />
  pinMode(pinLEDright, OUTPUT);<br />
  pinMode(pinLEDfront, OUTPUT);<br />
  pinMode(pinPIRleft, INPUT);<br />
  pinMode(pinPIRright, INPUT);<br />
  pinMode(pinPIRfront, INPUT);<br />
  myservo.attach(9);<br />
}</p>
<p>void loop() {</p>
<p>  if (digitalRead(pinPIRleft) == LOW) {<br />
    digitalWrite(pinLEDleft, HIGH);<br />
    if ((pos = 1) &amp;&amp; (digitalRead(pinPIRleft) == HIGH)) {<br />
      pos -= 1;<br />
      myservo.write(pos);<br />
      delay(15);<br />
    }<br />
  } else {<br />
    digitalWrite(pinLEDright, LOW);<br />
  }</p>
<p>  if ((digitalRead(pinPIRleft) == LOW) &amp;&amp; (digitalRead(pinPIRright) == LOW)) {</p>
<p>  }<br />
}</p>
<p>I&#8217;m stuck on the servo moving part, I want to make it so when the front PIR is on the sensor stops in its place until PIR left or right is the only one on please help me wright the last bit</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: john</title>
		<link>http://luckylarry.co.uk/arduino-projects/arduino-very-basic-motion-tracking-with-2-pir-sensors/comment-page-1/#comment-1435</link>
		<dc:creator>john</dc:creator>
		<pubDate>Thu, 18 Mar 2010 20:30:28 +0000</pubDate>
		<guid isPermaLink="false">http://luckylarry.co.uk/?p=298#comment-1435</guid>
		<description>thanks a million!!! im ordering the parts soon and i will keep you posted.</description>
		<content:encoded><![CDATA[<p>thanks a million!!! im ordering the parts soon and i will keep you posted.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: larry</title>
		<link>http://luckylarry.co.uk/arduino-projects/arduino-very-basic-motion-tracking-with-2-pir-sensors/comment-page-1/#comment-1431</link>
		<dc:creator>larry</dc:creator>
		<pubDate>Thu, 18 Mar 2010 09:30:18 +0000</pubDate>
		<guid isPermaLink="false">http://luckylarry.co.uk/?p=298#comment-1431</guid>
		<description>Hey John, welcome to working with Arduino!
You can use any of these parts in the US it&#039;ll all work the same so there&#039;ll be no difference at least not at this level. In fact you&#039;ll probably find it much easier to get parts in the US - checkout sparkfun.com they have a few bits.
You&#039;ll be glad to know I&#039;m a complete novice and if I can do these projects then anyone can - I&#039;m mainly a programmer so I&#039;m now beginning to find my limits when dealing with schematics and electronics.
Regarding the sketch you could easily add in another few PIR sensors and LEDs. Let me know how you get on and I&#039;ll give you a hand if you get stuck.
Larry.</description>
		<content:encoded><![CDATA[<p>Hey John, welcome to working with Arduino!</p>
<p>You can use any of these parts in the US it&#8217;ll all work the same so there&#8217;ll be no difference at least not at this level. In fact you&#8217;ll probably find it much easier to get parts in the US &#8211; checkout sparkfun.com they have a few bits.</p>
<p>You&#8217;ll be glad to know I&#8217;m a complete novice and if I can do these projects then anyone can &#8211; I&#8217;m mainly a programmer so I&#8217;m now beginning to find my limits when dealing with schematics and electronics.</p>
<p>Regarding the sketch you could easily add in another few PIR sensors and LEDs. Let me know how you get on and I&#8217;ll give you a hand if you get stuck.</p>
<p>Larry.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: john</title>
		<link>http://luckylarry.co.uk/arduino-projects/arduino-very-basic-motion-tracking-with-2-pir-sensors/comment-page-1/#comment-1429</link>
		<dc:creator>john</dc:creator>
		<pubDate>Wed, 17 Mar 2010 20:13:04 +0000</pubDate>
		<guid isPermaLink="false">http://luckylarry.co.uk/?p=298#comment-1429</guid>
		<description>one more thing can you sketch up this same thing but have one more sensor and led? thanks!!!</description>
		<content:encoded><![CDATA[<p>one more thing can you sketch up this same thing but have one more sensor and led? thanks!!!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
