Web edits
[beagleboard.org.git] / db / 2640.xml
blob8993d0c7ea2e3c045e1e62bbfc173699437582e8
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="2640" name="analogWrite" prototype="Page" created="1368744741967" lastModified="1376942759668">
5   <hop:parent idref="2471" prototyperef="Page"/>
6     <is_xhtml type="boolean">true</is_xhtml>
7     <http_remotehost>192.94.94.106</http_remotehost>
8     <http_language>en-US,en;q=0.8</http_language>
9     <uri>analogWrite</uri>
10     <http_browser>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36</http_browser>
11     <time type="date">19.08.2013 15:05:59 CDT</time>
12     <hopsession>192.94.94.172.24.115.1w0b3ne8n8y0m</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;analogWrite(pin, value, [freq], [callback])&lt;/h1&gt;\r
21 &lt;p&gt;Output a pulse width modulated signal on pin.&lt;/p&gt;\r
22 &lt;p&gt;The name &apos;analogWrite&apos; comes from other open source libraries with\r
23     recognition that a PWM tied to a low-pass filter will produce an analog\r
24     voltage level.  A PWM can also be used to control some types of motors.\r
25     Read more about PWMs on the &lt;a href=&quot;https://en.wikipedia.org/wiki/Pulse-width_modulation&quot;&gt;\r
26         Wikipedia pulse-width modulation page\r
27     &lt;/a&gt;.\r
28 &lt;/p&gt;\r
29 &lt;p&gt;Valid pins are highlighted in \r
30 yellow with &quot;PWM&quot; in their names (timers not yet supported):&lt;br /&gt;\r
31     &lt;img src=&quot;http://beagleboard.org/static/images/cape-headers-pwm.png&quot; width=&quot;70%&quot; /&gt;\r
32 &lt;/p&gt;\r
33 &lt;p&gt;&lt;strong&gt;&lt;em&gt;Note:&lt;/em&gt; This function is currently incompatible with pinMode\r
34     which may force the pin mux to GPIO mode only.\r
35 &lt;/strong&gt;&lt;/p&gt;\r
36 &lt;h2&gt;Arguments&lt;/h2&gt;\r
37 &lt;ul&gt;\r
38  &lt;li&gt;&lt;em&gt;pin&lt;/em&gt;: the &lt;a href=&quot;/Support/BoneScript/#pin&quot;&gt;BeagleBone pin&lt;/a&gt; identifier&lt;/li&gt;\r
39  &lt;li&gt;&lt;em&gt;value&lt;/em&gt;: duty cycle of the PWM as a value between 0 and 1&lt;/li&gt;\r
40  &lt;li&gt;&lt;em&gt;freq&lt;/em&gt;: frequency of the PWM in Hz (default is 2kHz)&lt;/li&gt;\r
41  &lt;li&gt;&lt;em&gt;callback&lt;/em&gt;: called upon completion&lt;/li&gt;\r
42 &lt;/ul&gt;\r
43 &lt;h2&gt;Return value&lt;/h2&gt;\r
44 &lt;ul&gt;\r
45  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/#true&quot;&gt;true&lt;/a&gt; if successful&lt;/li&gt;\r
46  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/#false&quot;&gt;false&lt;/a&gt; on failure&lt;/li&gt;\r
47 &lt;/ul&gt;\r
48 &lt;h2&gt;callback(x)&lt;/h2&gt;\r
49 &lt;ul&gt;\r
50  &lt;li&gt;&lt;em&gt;x.err&lt;/em&gt;: error status message&lt;/li&gt;\r
51 &lt;/ul&gt;\r
52 &lt;h2&gt;Example\r
53  &lt;button class=&quot;dynlink&quot; onclick=&quot;demoRun(&apos;code&apos;)&quot;&gt;run&lt;/button&gt;\r
54  &lt;button class=&quot;dynlink&quot; onclick=&quot;demoRestore(&apos;code&apos;)&quot;&gt;restore&lt;/button&gt;\r
55 &lt;/h2&gt;\r
56 &lt;pre id=&quot;code&quot; class=&quot;use-editor&quot; style=&quot;height:60px;&quot;&gt;\r
57 var b = require(&apos;bonescript&apos;);\r
58 b.analogWrite(&apos;P9_14&apos;, 0.7, 2000, printJSON);\r
59 function printJSON(x) { console.log(JSON.stringify(x)); }\r
60 &lt;/pre&gt;\r
61 &lt;div readonly id=&apos;console-output&apos; style=&quot;height:80px;&quot;&gt;&lt;/div&gt;\r
62 &lt;h2&gt;Build and execute instructions&lt;/h2&gt;\r
63 &lt;h2&gt;See also&lt;/h2&gt;\r
64 &lt;h3&gt;Topics&lt;/h3&gt;\r
65 &lt;ul&gt;\r
66  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/#headers&quot;&gt;BeagleBone expansion headers&lt;/a&gt;&lt;/li&gt;\r
67  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/#pwm&quot;&gt;PWM&lt;/a&gt;&lt;/li&gt;\r
68 &lt;/ul&gt;\r
69 &lt;h3&gt;Related functions&lt;/h3&gt;\r
70 &lt;ul&gt;\r
71  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/#require&quot;&gt;require&lt;/a&gt;&lt;/li&gt;\r
72  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/pinMode&quot;&gt;pinMode&lt;/a&gt;&lt;/li&gt;\r
73 &lt;/ul&gt;\r
74 &lt;h3&gt;Examples&lt;/h3&gt;\r
75 &lt;ul&gt;\r
76  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/cape_bacon&quot;&gt;Bacon Cape&lt;/a&gt;&lt;/li&gt;\r
77  &lt;li&gt;&lt;a href=&quot;/Support/BoneScript/educationalBoosterPack&quot;&gt;Educational BoosterPack&lt;/a&gt;&lt;/li&gt;\r
78 &lt;/ul&gt;\r
79 &lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;</body>
80     <pseudoparent idref="2471" prototyperef="Page"/>
81     <http_referer>http://beagleboard.org/support/BoneScript/analogWrite/edit</http_referer>
82     <http_host>beagleboard.org</http_host>
83     <user>jkridner@gmail.com</user>
84     <lang>en-us</lang>
85   </hopobject>
86 </xmlroot>