1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <?xml-stylesheet type="text/xsl" href="helma.xsl"?>
3 <xmlroot xmlns:hop="http://www.helma.org/docs/guide/features/database">
4 <hopobject id="2836" name="PIRMotionSensor" prototype="Page" created="1373039502953" lastModified="1387489171923">
5 <hop:parent idref="2471" prototyperef="Page"/>
6 <is_xhtml type="boolean">true</is_xhtml>
7 <http_remotehost>192.94.94.105</http_remotehost>
8 <http_language>en-US,en;q=0.8,fr;q=0.6</http_language>
9 <uri>PIRMotionSensor</uri>
10 <http_browser>Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36</http_browser>
11 <time type="date">19.12.2013 15:39:31 CST</time>
12 <hopsession>192.94.94.9otttzsp6btn</hopsession>
13 <body><script src="/static/bonescript-demo.js"></script>
\r
14 <div id='side-menu' class="t3_sidebar">
\r
15 <ul class="left-menu"><strong>Navigation</strong>
\r
16 <li><a href="/static/side-menu.html">Menu contents</a></li>
\r
19 <div class="t3_content_1"><div id='connect-status'></div><div id="content_child">
\r
20 <h1>Demo: PIR Motion Sensor</h1>
\r
21 <p> The PIR Motion Sensor, or Passive Infrared Sensor, is a sensor that takes a snapshot of the room and sets the
\r
22 'alarm' pin to 'LOW' if it detects changes in heat. Since this sensor is an <a href="http://en.wikipedia.org/wiki/Open_collector">open collector</a>,
\r
23 it needs a pull-up resistor on the alarm pin, which allows multiple motion sensors to be connected on a single input pin. If motion is detected in this
\r
24 demo, it will output "Motion Detected" on the console and will turn on the LED.
\r
29 <button class="dynlink" onclick="demoRun('code')">run</button>
\r
30 <button class="dynlink" onclick="demoRestore('code')">restore</button>
\r
32 <pre id="code" class="use-editor" style="height:300px;">
\r
33 var b = require('bonescript');
\r
34 var led = "P8_13";
\r
35 b.pinMode(led, 'out');
\r
36 b.pinMode('P8_19', b.INPUT);
\r
37 setInterval(checkPIR, 2500); // Checks the Sensor Every 2.5 Seconds
\r
39 function checkPIR(){
\r
40 b.digitalRead('P8_19', printStatus);
\r
43 function printStatus(x) {
\r
45 b.digitalWrite(led, 1);
\r
46 console.log("Motion Detected");
\r
49 console.log("No Motion Detected");
\r
50 b.digitalWrite(led, 0);
\r
54 <div readonly id='console-output' style="height:100px;"></div>
\r
55 <br></br>
\r
56 <img align="right" width="65%" src="http://beagleboard.org/static/uploads/Motion.PNG"/>
\r
57 <br></br>
\r
58 <h2>Build and execute instructions</h2>
\r
60 <li>Connect the '+' pin from the sensor to 'P9_5' of the BeagleBoard in series with a 10kohm resistor as shown on the right.</li>
\r
61 <li>Connect the '-' pin from the sensor to 'P9_1' of the BeagleBoard.</li>
\r
62 <li>Connect the 'AL' pin from the sensor to 'P8_19' of the BeagleBoard in series with a 10kohm resistor as shown on the right.</li>
\r
63 <li>Connect the LED with a 470ohm resistor as shown on the right </li>
\r
64 <li>Click "Run" on the code. Every 2.5 seconds, the console will tell you if there was motion detected. If there
\r
65 was motion detected, the LED will also turn on.
\r
69 <h2>See also</h2>
\r
70 <h3>Related functions</h3>
\r
72 <li><a href="/Support/BoneScript/#require">require</a></li>
\r
73 <li><a href="http://beagleboard.org/Support/BoneScript/digitalRead/">digitalRead</a></li>
\r
74 <li><a href="http://beagleboard.org/Support/BoneScript/#timers">setInterval</a></li>
\r
75 <li><a href="http://beagleboard.org/Support/BoneScript/digitalWrite/">digitalWrite</a></li>
\r
79 <h3>Where to buy</h3>
\r
81 <li> <a href="http://elinux.org/CircuitCo:BeagleBone_Breadboard#Distributors">BreadBoard</a></li>
\r
82 <li><a href="https://www.sparkfun.com/products/9590">External LED</a></li>
\r
83 <li><a href="https://www.sparkfun.com/products/11026">Jumper wires</a></li>
\r
84 <li> <a href="https://www.sparkfun.com/products/8630">PIR motion sensor</a></li>
\r
85 <li> <a href="https://www.sparkfun.com/search/products?sort_by=relevance%7Casc&per_page=500&term=resistor">Resistors</a></li>
\r
89 <h2>See it in action</h2>
\r
90 <iframe width="560" height="315" src="//www.youtube.com/embed/7pfQWB_-ZZU" frameborder="0" allowfullscreen></iframe></body>
91 <pseudoparent idref="2471" prototyperef="Page"/>
92 <http_referer>http://beagleboard.org/Support/BoneScript/PIRMotionSensor/edit</http_referer>
93 <http_host>beagleboard.org</http_host>
94 <user>jessica.lynne.callaway@gmail.com</user>