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="2779" name="digitalRead" prototype="Page" created="1371824739649" lastModified="1371824832512">
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 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36</http_browser>
11 <time type="date">21.06.2013 09:27:12 CDT</time>
12 <hopsession>127.0.0.192.94.94.z5cudt01kfu3</hopsession>
13 <body><script src="/static/bonescript-demo.js"></script>
\r
14 <h2>BoneScript</h2>
\r
16 <div id='side-menu' class="t3_sidebar">
\r
17 <ul class="left-menu">
\r
18 <strong>Navigation</strong>
\r
19 <li><a href="/Support/BoneScript/menu/">Menu contents</a></li>
\r
22 <div class="t3_content_1">
\r
23 <div id='connect-status'></div>
\r
24 <div id="content_child">
\r
26 <h1>digitalRead(pin, [callback])</h1>
\r
27 <p>Read the status of a digital I/O pin.</p>
\r
28 <h2>Arguments</h2>
\r
30 <li><em>pin</em>: the <a href="/Support/BoneScript/#pin">BeagleBone pin</a> identifier</li>
\r
31 <li><em>callback</em>: called upon completion</li>
\r
33 <h2>Return value</h2>
\r
35 <li><a href="/Support/BoneScript/#HIGH">HIGH</a> if pin is HIGH</li>
\r
36 <li><a href="/Support/BoneScript/#LOW">LOW</a> if pin is LOW</li>
\r
38 <h2>callback(x)</h2>
\r
40 <li><em>x.value</em>: return value</li>
\r
41 <li><em>x.err</em>: error status message</li>
\r
44 <button class="dynlink" onclick="demoRun('code')">run</button>
\r
45 <button class="dynlink" onclick="demoRestore('code')">restore</button>
\r
47 <pre id="code" class="use-editor" style="height: 140px;">
\r
48 var b = require('bonescript');
\r
49 b.pinMode('P8_19', b.INPUT);
\r
50 b.digitalRead('P8_19', printStatus);
\r
51 function printStatus(x) {
\r
52 console.log('x.value = ' + x.value);
\r
53 console.log('x.err = ' + x.err);
\r
55 <div readonly id='console-output' style='height: 80px;'></div>
\r
56 <h2>Build and execute instructions</h2>
\r
58 <li>Apply 0V to P8_19 and run the example code.</li>
\r
59 <li>Apply 3.3V to P8_19 and run the example code again.</li>
\r
60 <li>Alter the code to look at inputs on other pins.</li>
\r
62 <h2>See also</h2>
\r
63 <h3>Topics</h3>
\r
65 <li><a href="/Support/bone101/#headers">BeagleBone expansion headers</a></li>
\r
66 <li><a href="/Support/BoneScript/#digitalio">Digital I/O</a></li>
\r
68 <h3>Related functions</h3>
\r
70 <li><a href="/Support/BoneScript/#require">require</a></li>
\r
71 <li><a href="/Support/BoneScript/pinMode/">pinMode</a></li>
\r
72 <li><a href="/Support/BoneScript/digitalWrite/">digitalWrite</a></li>
\r
73 <li><a href="/Support/BoneScript/attachInterrupt/">attachInterrupt</a></li>
\r
75 <h3>Examples</h3>
\r
77 <li><a href="/Support/BoneScript/cape_bacon/">Bacon Cape</a></li>
\r
79 </div></div>
\r
80 <div style="clear:both;"></div></body>
81 <pseudoparent idref="2471" prototyperef="Page"/>
82 <http_referer>http://beagleboard.org/support/BoneScript/digitalRead/edit</http_referer>
83 <http_host>beagleboard.org</http_host>
84 <user>blog.hangerhead.com</user>