Web edits
[beagleboard.org.git] / db / 2836.xml
blob3809f4ba072dcdd8bad43abe81af3fd3b798b8e6
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>&lt;script src=&quot;/static/bonescript-demo.js&quot;&gt;&lt;/script&gt;\r
14 &lt;div id=&apos;side-menu&apos; class=&quot;t3_sidebar&quot;&gt;\r
15     &lt;ul class=&quot;left-menu&quot;&gt;&lt;strong&gt;Navigation&lt;/strong&gt;\r
16         &lt;li&gt;&lt;a href=&quot;/static/side-menu.html&quot;&gt;Menu contents&lt;/a&gt;&lt;/li&gt;\r
17     &lt;/ul&gt;\r
18 &lt;/div&gt;\r
19 &lt;div class=&quot;t3_content_1&quot;&gt;&lt;div id=&apos;connect-status&apos;&gt;&lt;/div&gt;&lt;div id=&quot;content_child&quot;&gt;\r
20 &lt;h1&gt;Demo: PIR Motion Sensor&lt;/h1&gt;\r
21 &lt;p&gt;  The PIR Motion Sensor, or Passive Infrared Sensor, is a sensor that takes a snapshot of the room and sets the\r
22 &apos;alarm&apos; pin to &apos;LOW&apos; if it detects changes in heat. Since this sensor is an  &lt;a href=&quot;http://en.wikipedia.org/wiki/Open_collector&quot;&gt;open collector&lt;/a&gt;,\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 &quot;Motion Detected&quot; on the console and will turn on the LED.\r
25 &lt;/p&gt;\r
28 &lt;h2&gt;Example\r
29  &lt;button class=&quot;dynlink&quot; onclick=&quot;demoRun(&apos;code&apos;)&quot;&gt;run&lt;/button&gt;\r
30  &lt;button class=&quot;dynlink&quot; onclick=&quot;demoRestore(&apos;code&apos;)&quot;&gt;restore&lt;/button&gt;\r
31 &lt;/h2&gt;\r
32 &lt;pre id=&quot;code&quot; class=&quot;use-editor&quot; style=&quot;height:300px;&quot;&gt;\r
33 var b = require(&apos;bonescript&apos;);\r
34 var led = &quot;P8_13&quot;;\r
35 b.pinMode(led, &apos;out&apos;);\r
36 b.pinMode(&apos;P8_19&apos;, b.INPUT);\r
37 setInterval(checkPIR, 2500); // Checks the Sensor Every 2.5 Seconds\r
39 function checkPIR(){\r
40 b.digitalRead(&apos;P8_19&apos;, printStatus);\r
41 }\r
43 function printStatus(x) {\r
44     if(x.value === 0){\r
45          b.digitalWrite(led, 1);\r
46     console.log(&quot;Motion Detected&quot;);\r
47     }\r
48     else{\r
49     console.log(&quot;No Motion Detected&quot;);\r
50          b.digitalWrite(led, 0);\r
51     }\r
52 }\r
53 &lt;/pre&gt;\r
54 &lt;div readonly id=&apos;console-output&apos; style=&quot;height:100px;&quot;&gt;&lt;/div&gt;\r
55 &lt;br&gt;&lt;/br&gt;\r
56 &lt;img align=&quot;right&quot; width=&quot;65%&quot; src=&quot;http://beagleboard.org/static/uploads/Motion.PNG&quot;/&gt;\r
57 &lt;br&gt;&lt;/br&gt;\r
58 &lt;h2&gt;Build and execute instructions&lt;/h2&gt;\r
59 &lt;ul&gt;\r
60  &lt;li&gt;Connect the &apos;+&apos; pin from the sensor to &apos;P9_5&apos; of the BeagleBoard in series with a 10kohm resistor as shown on the right.&lt;/li&gt;\r
61  &lt;li&gt;Connect the &apos;-&apos; pin from the sensor to &apos;P9_1&apos; of the BeagleBoard.&lt;/li&gt;\r
62  &lt;li&gt;Connect the &apos;AL&apos; pin from the sensor to &apos;P8_19&apos; of the BeagleBoard in series with a 10kohm resistor as shown on the right.&lt;/li&gt;\r
63  &lt;li&gt;Connect the LED with a 470ohm resistor as shown on the right &lt;/li&gt;\r
64  &lt;li&gt;Click &quot;Run&quot; 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
66  &lt;/li&gt;\r
67 &lt;/ul&gt;\r
69 &lt;h2&gt;See also&lt;/h2&gt;\r
70 &lt;h3&gt;Related functions&lt;/h3&gt;\r
71 &lt;ul&gt;\r
72  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/#require&quot;&gt;require&lt;/a&gt;&lt;/li&gt;\r
73  &lt;li&gt;&lt;a href=&quot;http://beagleboard.org/Support/BoneScript/digitalRead/&quot;&gt;digitalRead&lt;/a&gt;&lt;/li&gt;\r
74  &lt;li&gt;&lt;a href=&quot;http://beagleboard.org/Support/BoneScript/#timers&quot;&gt;setInterval&lt;/a&gt;&lt;/li&gt;\r
75  &lt;li&gt;&lt;a href=&quot;http://beagleboard.org/Support/BoneScript/digitalWrite/&quot;&gt;digitalWrite&lt;/a&gt;&lt;/li&gt;\r
76 &lt;/ul&gt;\r
79 &lt;h3&gt;Where to buy&lt;/h3&gt;\r
80 &lt;ul&gt;\r
81 &lt;li&gt; &lt;a href=&quot;http://elinux.org/CircuitCo:BeagleBone_Breadboard#Distributors&quot;&gt;BreadBoard&lt;/a&gt;&lt;/li&gt;\r
82  &lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/9590&quot;&gt;External LED&lt;/a&gt;&lt;/li&gt;\r
83 &lt;li&gt;&lt;a href=&quot;https://www.sparkfun.com/products/11026&quot;&gt;Jumper wires&lt;/a&gt;&lt;/li&gt;\r
84 &lt;li&gt; &lt;a href=&quot;https://www.sparkfun.com/products/8630&quot;&gt;PIR motion sensor&lt;/a&gt;&lt;/li&gt;\r
85 &lt;li&gt; &lt;a href=&quot;https://www.sparkfun.com/search/products?sort_by=relevance%7Casc&amp;per_page=500&amp;term=resistor&quot;&gt;Resistors&lt;/a&gt;&lt;/li&gt;\r
87 &lt;/ul&gt;\r
89 &lt;h2&gt;See it in action&lt;/h2&gt;\r
90 &lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;//www.youtube.com/embed/7pfQWB_-ZZU&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;</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>
95     <lang>en-us</lang>
96   </hopobject>
97 </xmlroot>