<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Code Koala (breadboard)</title><link>http://www.codekoala.com/</link><description></description><atom:link type="application/rss+xml" href="http://www.codekoala.com/categories/breadboard.xml" rel="self"></atom:link><language>en</language><lastBuildDate>Mon, 14 Dec 2015 22:04:42 GMT</lastBuildDate><generator>https://getnikola.com/</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>PIR Motion Sensor + LCD Screen + Arduino Uno</title><link>http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/</link><dc:creator>Josh VanderLinden</dc:creator><description>&lt;div&gt;&lt;p&gt;For one reason or another, I've recently had the urge to follow in my father's
footsteps and start tinkering with electronics.  He's basically a wizard.  He
has fixed a lot of appliances that others tossed out the door without the
slightest bit of investigation.  I think he did this with the monitor I had
hooked up to my very first computer.  He just popped open the case, found the
problem, soldered some solution in there, and that monitor worked for probably
a decade afterwards.  Amazing stuff.&lt;/p&gt;
&lt;p&gt;Anyway, I have an itch to create a laser trip wire (don't ask).  I took a basic
electronics class my freshman year in college, so I am already familiar with
resistors, capacitors, ICs, breadboards, soldering, etc.  It doesn't seem like
a very daunting task to create that trip wire, but I'm starting fresh with
electronics (it's been a good 8 or 9 years since I last soldered or anything
like that).&lt;/p&gt;
&lt;p&gt;One of my co-workers mentioned the Arduino as something to get me started on
the trip wire, so I started doing some research here and there.  The more I
read, the more excited I got.  I wanted soo badly to buy all of the junk that
I'd need to start tinkering with an Arduino, but I didn't think my wife would
appreciate that--especially around Christmas time.&lt;/p&gt;
&lt;p&gt;Several of my awesome relatives sent me very generous gift cards for Christmas
this year, which finally gave me the opportunity to buy a load of stuff for the
Arduino without feeling bad.  So I ordered loads of stuff.  Most of it is here,
some of it is still on its way.  My Arduino Uno arrived around noon today, and
I haven't been able to stop tinkering!  It's really a lot of fun, and stupid
easy even if you're not a programmer!&lt;/p&gt;
&lt;p&gt;I started with the basic "oooh, blinking LEDs!" sort of projects (or "sketches"
in Arduino parlance).  Then I moved on to tweak those to work with multiple
LEDs.  There were a few different scenarios I ran though because two of my LEDs
weren't lighting up very well.  I guess I either hooked them up wrong or I
didn't seat them properly... whatever.&lt;/p&gt;
&lt;p&gt;The next project was when I hooked up a PIR (passive infrared) motion sensor
(&lt;a class="reference external" href="https://www.radioshack.com/product/index.jsp?productId=28386046"&gt;$9.99 at RadioShack&lt;/a&gt;) and installed &lt;a class="reference external" href="http://playground.arduino.cc/Code/PIRsense"&gt;a demo sketch&lt;/a&gt; that I found on the
Arduino wiki.  I wasn't quite sure how to wire everything for the PIR sensor,
so I took a look at &lt;a class="reference external" href="http://makezine.com/projects/pir-sensor-arduino-alarm/"&gt;this Make Magazine video&lt;/a&gt; to see one way of setting up
the circuit.  That one simply lights up an LED and makes some noise.  I just
made mine light up and LED since I don't have a buzzer (yet).&lt;/p&gt;
&lt;p&gt;Next I moved on to &lt;a class="reference external" href="http://www.hacktronics.com/LCDs/16-x-2-LCD-Black-on-Green/flypage.tpl.html"&gt;the LCD&lt;/a&gt;.  The package came with a 20x4 green-on-black
backlit LCD display, a 2.2k Ohm resistor, and a set of pins to connect the LCD
to my breadboard or whatever.  I actually soldered the pins onto the LCD
display board (wow, was that even more difficult than I remember!) so I would
have less of a hassle getting all of the contacts working.  Getting the LCD to
work was &lt;a class="reference external" href="http://www.hacktronics.com/Tutorials/arduino-character-lcd-tutorial.html"&gt;pretty easy&lt;/a&gt; after that.&lt;/p&gt;
&lt;p&gt;Then I took those two projects a bit further.  I'm certain others have done
this years ago, but I didn't use a sketch that was completely written for me
this time so I felt special enough to share :)  I added the PIR circuit from
before less the LED, merged pieces from both demo programs, and came up with a
motion sensor that would flash "INTRUDER ALERT!!" on the LCD screen a few times
when triggered.  Based on my testing, the sensor works extremely well (once
calibrated!!), and it will detect motion well across the open area of my
apartment (maybe a bit further than 20 feet)!&lt;/p&gt;
&lt;p&gt;I'm quite happy with my work, especially for not having "dealt with"
electronics for such a long time.  When I tried to share my success with some
of my friends, they wanted a video to prove I'm awesome (I guess?).  So here it
is.  Trust me, I know the video is horrible--I speak too quietly (baby sleeping
in next room), I stumble over my words (that's just me), and I neglected to
even offer you some music to rock out to as I blabber about this stuff.&lt;/p&gt;
&lt;iframe width="425" height="344" src="//www.youtube.com/embed/Qpc1emafaUs?rel=0&amp;amp;hd=1&amp;amp;wmode=transparent"&gt;&lt;/iframe&gt;&lt;p&gt;Here's the program I wrote/modified:&lt;/p&gt;
&lt;table class="codetable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-1"&gt;  1&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-2"&gt;  2&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-3"&gt;  3&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-4"&gt;  4&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-5"&gt;  5&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-6"&gt;  6&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-7"&gt;  7&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-8"&gt;  8&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-9"&gt;  9&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-10"&gt; 10&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-11"&gt; 11&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-12"&gt; 12&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-13"&gt; 13&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-14"&gt; 14&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-15"&gt; 15&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-16"&gt; 16&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-17"&gt; 17&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-18"&gt; 18&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-19"&gt; 19&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-20"&gt; 20&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-21"&gt; 21&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-22"&gt; 22&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-23"&gt; 23&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-24"&gt; 24&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-25"&gt; 25&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-26"&gt; 26&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-27"&gt; 27&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-28"&gt; 28&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-29"&gt; 29&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-30"&gt; 30&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-31"&gt; 31&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-32"&gt; 32&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-33"&gt; 33&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-34"&gt; 34&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-35"&gt; 35&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-36"&gt; 36&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-37"&gt; 37&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-38"&gt; 38&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-39"&gt; 39&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-40"&gt; 40&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-41"&gt; 41&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-42"&gt; 42&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-43"&gt; 43&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-44"&gt; 44&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-45"&gt; 45&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-46"&gt; 46&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-47"&gt; 47&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-48"&gt; 48&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-49"&gt; 49&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-50"&gt; 50&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-51"&gt; 51&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-52"&gt; 52&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-53"&gt; 53&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-54"&gt; 54&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-55"&gt; 55&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-56"&gt; 56&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-57"&gt; 57&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-58"&gt; 58&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-59"&gt; 59&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-60"&gt; 60&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-61"&gt; 61&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-62"&gt; 62&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-63"&gt; 63&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-64"&gt; 64&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-65"&gt; 65&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-66"&gt; 66&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-67"&gt; 67&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-68"&gt; 68&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-69"&gt; 69&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-70"&gt; 70&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-71"&gt; 71&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-72"&gt; 72&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-73"&gt; 73&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-74"&gt; 74&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-75"&gt; 75&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-76"&gt; 76&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-77"&gt; 77&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-78"&gt; 78&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-79"&gt; 79&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-80"&gt; 80&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-81"&gt; 81&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-82"&gt; 82&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-83"&gt; 83&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-84"&gt; 84&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-85"&gt; 85&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-86"&gt; 86&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-87"&gt; 87&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-88"&gt; 88&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-89"&gt; 89&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-90"&gt; 90&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-91"&gt; 91&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-92"&gt; 92&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-93"&gt; 93&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-94"&gt; 94&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-95"&gt; 95&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-96"&gt; 96&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-97"&gt; 97&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-98"&gt; 98&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-99"&gt; 99&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-100"&gt;100&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-101"&gt;101&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-102"&gt;102&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-103"&gt;103&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-104"&gt;104&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-105"&gt;105&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-106"&gt;106&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-107"&gt;107&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-108"&gt;108&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-109"&gt;109&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-110"&gt;110&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-111"&gt;111&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-112"&gt;112&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-113"&gt;113&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-114"&gt;114&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-115"&gt;115&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-116"&gt;116&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-117"&gt;117&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-118"&gt;118&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-119"&gt;119&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-120"&gt;120&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-121"&gt;121&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-122"&gt;122&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-123"&gt;123&lt;/a&gt;
&lt;a href="http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/#rest_code_9d7c5efbc594408ebb655506d906f191-124"&gt;124&lt;/a&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;pre class="code c"&gt;&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-1"&gt;&lt;/a&gt; &lt;span class="cm"&gt;/*&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-2"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * //////////////////////////////////////////////////&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-3"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * //making sense of the Parallax PIR sensor's output&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-4"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * //////////////////////////////////////////////////&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-5"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  *&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-6"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * Switches a LED according to the state of the sensors output pin. Determines&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-7"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * the beginning and end of continuous motion sequences.&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-8"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  *&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-9"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * @author: Kristian Gohlke / krigoo (_) gmail (_) com / http://krx.at&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-10"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * @author: Josh VanderLinden / codekoala (.) gmail (@) com / http://www.codekoala.com&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-11"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * @date:   3 Jan 2011&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-12"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  *&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-13"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * kr1 (cleft) 2006&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-14"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * Released under a creative commons "Attribution-NonCommercial-ShareAlike 2.0" license&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-15"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * http://creativecommons.org/licenses/by-nc-sa/2.0/de/&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-16"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  *&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-17"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  *&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-18"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * The Parallax PIR Sensor is an easy to use digital infrared motion sensor module.&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-19"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * (http://www.parallax.com/detail.asp?product_id=555-28027)&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-20"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  *&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-21"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * The sensor's output pin goes to HIGH if motion is present. However, even if&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-22"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * motion is present it goes to LOW from time to time, which might give the&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-23"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * impression no motion is present. This program deals with this issue by&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-24"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * ignoring LOW-phases shorter than a given time, assuming continuous motion is&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-25"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  * present during these phases.&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-26"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  *&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-27"&gt;&lt;/a&gt;&lt;span class="cm"&gt;  */&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-28"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-29"&gt;&lt;/a&gt; &lt;span class="cp"&gt;#include &amp;lt;LiquidCrystal.h&amp;gt;&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-30"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-31"&gt;&lt;/a&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;calibrationTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// seconds to calibrate PIR&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-32"&gt;&lt;/a&gt; &lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="kt"&gt;unsigned&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;pause&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// timeout before we "all" motion has ceased&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-33"&gt;&lt;/a&gt; &lt;span class="kt"&gt;long&lt;/span&gt; &lt;span class="kt"&gt;unsigned&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;lowIn&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// the time when the sensor outputs a low impulse&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-34"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-35"&gt;&lt;/a&gt; &lt;span class="n"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;lockLow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-36"&gt;&lt;/a&gt; &lt;span class="n"&gt;boolean&lt;/span&gt; &lt;span class="n"&gt;takeLowTime&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-37"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-38"&gt;&lt;/a&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;flashCnt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// number of times the LCD will flash when there's motion&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-39"&gt;&lt;/a&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;flashDelay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// number of ms to wait while flashing LCD&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-40"&gt;&lt;/a&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;pirPin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;    &lt;span class="c1"&gt;// the digital pin connected to the PIR sensor's output&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-41"&gt;&lt;/a&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;lcdPin&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// pin connected to LCD&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-42"&gt;&lt;/a&gt; &lt;span class="n"&gt;LiquidCrystal&lt;/span&gt; &lt;span class="nf"&gt;lcd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-43"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-44"&gt;&lt;/a&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-45"&gt;&lt;/a&gt;     &lt;span class="c1"&gt;// Calibrates the PIR&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-46"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-47"&gt;&lt;/a&gt;     &lt;span class="n"&gt;Serial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;begin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9600&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-48"&gt;&lt;/a&gt;     &lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pirPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;INPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-49"&gt;&lt;/a&gt;     &lt;span class="n"&gt;pinMode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lcdPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;OUTPUT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-50"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-51"&gt;&lt;/a&gt;     &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pirPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-52"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-53"&gt;&lt;/a&gt;     &lt;span class="n"&gt;clearLcd&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-54"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-55"&gt;&lt;/a&gt;     &lt;span class="c1"&gt;// give the sensor some time to calibrate&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-56"&gt;&lt;/a&gt;     &lt;span class="n"&gt;lcd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setCursor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-57"&gt;&lt;/a&gt;     &lt;span class="n"&gt;lcd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Calibrating..."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-58"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-59"&gt;&lt;/a&gt;     &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;calibrationTime&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-60"&gt;&lt;/a&gt;         &lt;span class="n"&gt;lcd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-61"&gt;&lt;/a&gt;         &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-62"&gt;&lt;/a&gt;     &lt;span class="p"&gt;}&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-63"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-64"&gt;&lt;/a&gt;     &lt;span class="n"&gt;lcd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"done"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-65"&gt;&lt;/a&gt;     &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-66"&gt;&lt;/a&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-67"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-68"&gt;&lt;/a&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;clearLcd&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-69"&gt;&lt;/a&gt;     &lt;span class="c1"&gt;// Clears the LCD, turns off the backlight&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-70"&gt;&lt;/a&gt;     &lt;span class="n"&gt;lcd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;begin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-71"&gt;&lt;/a&gt;     &lt;span class="n"&gt;lcd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-72"&gt;&lt;/a&gt;     &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lcdPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-73"&gt;&lt;/a&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-74"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-75"&gt;&lt;/a&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;alertLcd&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-76"&gt;&lt;/a&gt;     &lt;span class="c1"&gt;// Turns on the LCD backlight and notifies user of motion&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-77"&gt;&lt;/a&gt;     &lt;span class="n"&gt;lcd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setCursor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-78"&gt;&lt;/a&gt;     &lt;span class="n"&gt;digitalWrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lcdPin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-79"&gt;&lt;/a&gt;     &lt;span class="n"&gt;lcd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"INTRUDER ALERT!!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-80"&gt;&lt;/a&gt;     &lt;span class="n"&gt;lcd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setCursor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-81"&gt;&lt;/a&gt;     &lt;span class="n"&gt;lcd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"================"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-82"&gt;&lt;/a&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-83"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-84"&gt;&lt;/a&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;loop&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-85"&gt;&lt;/a&gt;     &lt;span class="c1"&gt;// Main execution loop&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-86"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-87"&gt;&lt;/a&gt;     &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pirPin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;HIGH&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-88"&gt;&lt;/a&gt;         &lt;span class="c1"&gt;// flash an alert a few times&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-89"&gt;&lt;/a&gt;         &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;flashCnt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-90"&gt;&lt;/a&gt;             &lt;span class="n"&gt;alertLcd&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-91"&gt;&lt;/a&gt;             &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flashDelay&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-92"&gt;&lt;/a&gt;             &lt;span class="n"&gt;lcd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;clear&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-93"&gt;&lt;/a&gt;             &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flashDelay&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-94"&gt;&lt;/a&gt;         &lt;span class="p"&gt;}&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-95"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-96"&gt;&lt;/a&gt;         &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lockLow&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-97"&gt;&lt;/a&gt;             &lt;span class="c1"&gt;// makes sure we wait for a transition to LOW before any further&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-98"&gt;&lt;/a&gt;             &lt;span class="c1"&gt;// output is made:&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-99"&gt;&lt;/a&gt;             &lt;span class="n"&gt;lockLow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-100"&gt;&lt;/a&gt;             &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-101"&gt;&lt;/a&gt;         &lt;span class="p"&gt;}&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-102"&gt;&lt;/a&gt;         &lt;span class="n"&gt;takeLowTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-103"&gt;&lt;/a&gt;     &lt;span class="p"&gt;}&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-104"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-105"&gt;&lt;/a&gt;     &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;digitalRead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pirPin&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;LOW&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-106"&gt;&lt;/a&gt;         &lt;span class="n"&gt;clearLcd&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-107"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-108"&gt;&lt;/a&gt;         &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;takeLowTime&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-109"&gt;&lt;/a&gt;             &lt;span class="c1"&gt;// save the time of the transition from high to LOW&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-110"&gt;&lt;/a&gt;             &lt;span class="c1"&gt;// make sure this is only done at the start of a LOW phase&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-111"&gt;&lt;/a&gt;             &lt;span class="n"&gt;lowIn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;millis&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-112"&gt;&lt;/a&gt;             &lt;span class="n"&gt;takeLowTime&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-113"&gt;&lt;/a&gt;         &lt;span class="p"&gt;}&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-114"&gt;&lt;/a&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-115"&gt;&lt;/a&gt;         &lt;span class="c1"&gt;// if the sensor is low for more than the given pause,&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-116"&gt;&lt;/a&gt;         &lt;span class="c1"&gt;// we assume that no more motion is going to happen&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-117"&gt;&lt;/a&gt;         &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;lockLow&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;millis&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;lowIn&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;pause&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-118"&gt;&lt;/a&gt;             &lt;span class="c1"&gt;// makes sure this block of code is only executed again after&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-119"&gt;&lt;/a&gt;             &lt;span class="c1"&gt;// a new motion sequence has been detected&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-120"&gt;&lt;/a&gt;             &lt;span class="n"&gt;lockLow&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-121"&gt;&lt;/a&gt;             &lt;span class="n"&gt;delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-122"&gt;&lt;/a&gt;         &lt;span class="p"&gt;}&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-123"&gt;&lt;/a&gt;     &lt;span class="p"&gt;}&lt;/span&gt;
&lt;a name="rest_code_9d7c5efbc594408ebb655506d906f191-124"&gt;&lt;/a&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;</description><category>arduino</category><category>breadboard</category><category>c</category><category>html</category><category>lcd</category><category>led</category><category>motion</category><category>open-source</category><category>pir</category><category>programming</category><category>projects</category><category>resistor</category><category>soldering</category><category>stupid</category><category>testing</category><category>work</category><guid>http://www.codekoala.com/posts/pir-motion-sensor-lcd-screen-arduino-uno/</guid><pubDate>Tue, 04 Jan 2011 09:35:00 GMT</pubDate></item></channel></rss>