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="2768" name="analogRead" prototype="Page" created="1371676191534" lastModified="1371676290452">
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>
10 <http_browser>Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36</http_browser>
11 <time type="date">19.06.2013 16:11:30 CDT</time>
12 <hopsession>127.0.0.192.91.66.1u05jlh65hfie</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 <!--- START CONTENT -->
\r
22 <h1>analogRead(pin, [callback])</h1>
\r
23 <p>Read the voltage at an analog input pin.</p>
\r
24 <h2>Arguments</h2>
\r
26 <li><em>pin</em>: the <a href="/Support/BoneScript/#pin">pin identifier</a></li>
\r
27 <li><em>callback</em>: called upon completion</li>
\r
29 <h2>Return value</h2>
\r
31 <li>Number from 0 to 1 where 0 is 0V and 1 is the maximum input voltage (1.8V)</li>
\r
33 <h2>callback(x)</h2>
\r
35 <li><em>x.value</em>: return value</li>
\r
36 <li><em>x.err</em>: error status message</li>
\r
39 <button class="dynlink" onclick="demoRun('code')">run</button>
\r
40 <button class="dynlink" onclick="demoRestore('code')">restore</button>
\r
42 <pre id="code" class="use-editor" style="height: 120px;">
\r
43 var b = require('bonescript');
\r
44 b.analogRead('P9_36', printStatus);
\r
45 function printStatus(x) {
\r
46 console.log('x.value = ' + x.value);
\r
47 console.log('x.err = ' + x.err);
\r
49 <div readonly id='console-output' style='height: 80px;'></div>
\r
50 <h2>Build and execute instructions</h2>
\r
52 <li>Apply voltage between 0V and 1.8V to P9_36 and run the example code.</li>
\r
53 <li>Adjust the voltage between 0V and 1.8V to P9_36 and run the example code again.</li>
\r
54 <li>Alter the code to look at inputs on other analog input pins.</li>
\r
56 <h2>See also</h2>
\r
57 <h3>Topics</h3>
\r
59 <li><a href="/Support/bone101/#headers">BeagleBone expansion headers</a></li>
\r
60 <li><a href="/Support/BoneScript/#analogio">Analog I/O</a></li>
\r
62 <h3>Related functions</h3>
\r
64 <li><a href="/Support/BoneScript/#require">require</a></li>
\r
65 <li><a href="/Support/BoneScript/analogWrite/">analogWrite</a></li>
\r
67 <h3>Examples</h3>
\r
69 <li><a href="/Support/BoneScript/cape_bacon/">Bacon Cape</a></li>
\r
71 <pseudoparent idref="2471" prototyperef="Page"/>
72 <http_referer>http://beagleboard.org/support/BoneScript/analogRead/edit</http_referer>
73 <http_host>beagleboard.org</http_host>
75 <user>rachelballdesign@gmail.com</user>