Log updates
[beagleboard.org.git] / db / 2814.xml
blobf042da0eae68723d2dc5fb5fece45f581486f1da
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="2814" name="new" prototype="Page" created="1372444995090" lastModified="1372456086158">
5   <hop:parent idref="2471" prototyperef="Page"/>
6     <is_xhtml type="boolean">true</is_xhtml>
7     <http_remotehost>127.0.0.1</http_remotehost>
8     <http_language>en-US,en;q=0.8</http_language>
9     <uri>new</uri>
10     <http_browser>Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.63 Safari/537.36</http_browser>
11     <time type="date">28.06.2013 16:48:06 CDT</time>
12     <hopsession>127.0.0.192.91.66.1g6zms0negvv3</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: Maxbotic Ultrasonic Sensor&lt;/h1&gt;\r
21 &lt;p&gt;  The LV-MaxSonar-EZ2 High Performance Sonar Range Finder provides very short\r
22 to long-range detection and ranging, in an incredibly small package. The sonar\r
23 detects objects from 0-254 inches and provides sonar range information from 6-inches\r
24 out to 254-inches with 1-inch resolution.\r
25 &lt;/p&gt;\r
26 &lt;i&gt;Note: Each time after the Sonar is powered up, it will calibrate\r
27 during it&apos;s first read cycle. The sensor uses this stored \r
28 information to range a close object. It is important that objects\r
29 not be close to the sensor during this calibration cycle. The\r
30 best sensitivity is obtained when it is clear for fourteen \r
31 inches, but good results are common when clear for at least\r
32 seven inches. If an object is too close during the calibration\r
33 cycle, the sensor may then ignore the objects at that distance.\r
34 To calibrate the LV-MAX Sonar, cycle power, then command a read\r
35 cycle.&lt;/i&gt;\r
37 &lt;/br&gt;\r
40 &lt;h2&gt;Example\r
41  &lt;button class=&quot;dynlink&quot; onclick=&quot;demoRun(&apos;code&apos;)&quot;&gt;run&lt;/button&gt;\r
42  &lt;button class=&quot;dynlink&quot; onclick=&quot;demoRestore(&apos;code&apos;)&quot;&gt;restore&lt;/button&gt;\r
43 &lt;/h2&gt;\r
44 &lt;pre id=&quot;code&quot; class=&quot;use-editor&quot; style=&quot;height:470px;&quot;&gt;\r
45 var b = require(&apos;bonescript&apos;);\r
46 var i =0;\r
48 /* Check the sensor values every 5 seconds*/\r
49 setInterval(read, 5000);\r
51 function read(){\r
52     b.analogRead(&apos;P9_40&apos;, printStatus);\r
53 }\r
54 function printStatus(x) {\r
55     console.log(&apos;x.value = &apos; + x.value);\r
56     distance(x.value);\r
57 }\r
59 /* Theoretical Values\r
60 Analog: (Vcc/512) / inch\r
61 5V: ~9.8mV / inch\r
62 3.3V: ~6.4mV/in */\r
63 function distance(i){\r
65 /* Makes a 100-number array in multiples of 9.8mV */\r
66 var myArray = [];\r
67 for(var m=1; m&lt;100; m++){\r
68     myArray[m]= 0.0098*m;\r
69 }\r
71 /*Calculates the distance, in inches, measured from the sensor */\r
72 for(var j=0; j&lt;myArray.length;j++){\r
73      if(myArray[j] &gt; i){\r
74          break;\r
75       }\r
76 }\r
77 console.log(&quot;There is an object &quot; + j + &quot; inches away.&quot;);\r
78 }\r
79 &lt;/pre&gt;\r
80 &lt;div readonly id=&apos;console-output&apos; style=&quot;height:100px;&quot;&gt;&lt;/div&gt;\r
81 &lt;br&gt;&lt;/br&gt;\r
82 &lt;img align=&quot;right&quot; width=&quot;60%&quot; src=&quot;http://beagleboard.org/static/uploads/Maxbotic%20Sensor.png&quot;/&gt;\r
83 &lt;br&gt;&lt;/br&gt;\r
84 &lt;h2&gt;Build and execute instructions&lt;/h2&gt;\r
85 &lt;ul&gt;\r
86  &lt;li&gt;Connect the &quot;GND&quot; pin from the sensor to P9.1 of the BeagleBoard.&lt;/li&gt;\r
87  &lt;li&gt;Connect the &quot;+5&quot; pin from the sensor to P9.3 of the BeagleBoard.&lt;/li&gt;\r
88  &lt;li&gt;Connect the AN pin from the sensor to P9.40 of the BeagleBoard.&lt;/li&gt;\r
89  &lt;li&gt;Click &quot;Run&quot; on the code and it will output the distance, in inches that your\r
90  sensor is detecting every 5 seconds.&lt;/li&gt;\r
91  &lt;li&gt;Move the sensor closer to or away from an object to see the change in distance.&lt;/li&gt;\r
92 &lt;/ul&gt;\r
94 &lt;h2&gt;See also&lt;/h2&gt;\r
95 &lt;h3&gt;Related functions&lt;/h3&gt;\r
96 &lt;ul&gt;\r
97  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/#require&quot;&gt;require&lt;/a&gt;&lt;/li&gt;\r
98  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/analogRead/&quot;&gt;analogRead&lt;/a&gt;&lt;/li&gt;\r
99  &lt;li&gt;&lt;a href=&quot;http://beagleboard.org/Support/BoneScript/#timers&quot;&gt;setInterval&lt;/a&gt;&lt;/li&gt;\r
100 &lt;/ul&gt;</body>
101     <pseudoparent idref="2471" prototyperef="Page"/>
102     <http_referer>http://beagleboard.org/Support/BoneScript/new/edit</http_referer>
103     <http_host>beagleboard.org</http_host>
104     <user>cortezjuanjr@gmail.com</user>
105     <lang>en-us</lang>
106   </hopobject>
107 </xmlroot>