Skip to content

Instantly share code, notes, and snippets.

@Dicetog
Forked from DiegoTc/CARD_0.html
Last active August 29, 2015 14:05
Show Gist options
  • Save Dicetog/da3e60056a1dc8cae0d0 to your computer and use it in GitHub Desktop.
Save Dicetog/da3e60056a1dc8cae0d0 to your computer and use it in GitHub Desktop.
Bone101 Tutorial
<h1 style="font-size: 2em; font-family: Arial, Verdana, Helvetica, sans-serif; color: rgb(180, 162, 121); line-height: normal;">analogRead(pin, [callback])</h1><p style="font-size: 1.1em; line-height: 1.3em; color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif;">Read the voltage at an analog input pin.</p><h2 style="font-size: 1.5em; font-family: Arial, Verdana, Helvetica, sans-serif; color: rgb(180, 162, 121); margin: 5px 0px; line-height: normal;">Arguments</h2><ul style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px;"><li><em>pin</em>: the&nbsp;<a href="http://beagleboard.org/Support/BoneScript/#pin" style="color: rgb(222, 114, 36);">pin identifier</a></li><li><em>callback</em>: called upon completion</li></ul><h2 style="font-size: 1.5em; font-family: Arial, Verdana, Helvetica, sans-serif; color: rgb(180, 162, 121); margin: 5px 0px; line-height: normal;">Return value</h2><ul style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px;"><li>Number from 0 to 1 where 0 is 0V and 1 is the maximum input voltage (1.8V)</li></ul><h2 style="font-size: 1.5em; font-family: Arial, Verdana, Helvetica, sans-serif; color: rgb(180, 162, 121); margin: 5px 0px; line-height: normal;">callback(x)</h2><ul style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px;"><li><em>x.value</em>: return value</li><li><em>x.err</em>: error status message</li></ul><div><span style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px;"><br></span></div><div><h2 style="font-family: Arial, Verdana, Helvetica, sans-serif; line-height: normal; color: rgb(180, 162, 121); margin: 5px 0px; font-size: 1.5em;">Build and execute instructions</h2><ul style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px;"><li>Apply voltage between 0V and 1.8V to P9_36 and run the example code that will be on the next card.</li><li>Adjust the voltage between 0V and 1.8V to P9_36 and run the example code again.</li><li>Alter the code to look at inputs on other analog input pins.</li></ul></div>
<h2 style="font-size: 1.5em; font-family: Arial, Verdana, Helvetica, sans-serif; color: rgb(180, 162, 121); margin: 5px 0px; line-height: normal;">Build and execute instructions</h2><ul style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px;"><li>Apply voltage between 0V and 1.8V to P9_36 and run the example code that will be on the next card.</li><li>Adjust the voltage between 0V and 1.8V to P9_36 and run the example code again.</li><li>Alter the code to look at inputs on other analog input pins.</li></ul>
var b = require('bonescript');
b.analogRead('P9_36', printStatus);
function printStatus(x) {
console.log('x.value = ' + x.value);
console.log('x.err = ' + x.err);
}
<div id="content_child" style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px;"><h2 style="font-size: 1.5em; font-family: Arial, Verdana, Helvetica, sans-serif; color: rgb(180, 162, 121); margin: 5px 0px;">See also</h2><h3 style="font-size: 1.2em; font-family: Arial, Verdana, Helvetica, sans-serif; color: rgb(180, 162, 121); margin: 5px 0px; font-weight: normal;">Topics</h3><ul><li><a href="http://beagleboard.org/Support/bone101/#headers" style="color: rgb(222, 114, 36);">BeagleBone expansion headers</a></li><li><a href="http://beagleboard.org/Support/BoneScript/#analogio" style="color: rgb(222, 114, 36);">Analog I/O</a></li></ul><h3 style="font-size: 1.2em; font-family: Arial, Verdana, Helvetica, sans-serif; color: rgb(180, 162, 121); margin: 5px 0px; font-weight: normal;">Related functions</h3><ul><li><a href="http://beagleboard.org/Support/BoneScript/#require" style="color: rgb(222, 114, 36);">require</a></li><li><a href="http://beagleboard.org/Support/BoneScript/analogWrite/" style="color: rgb(222, 114, 36);">analogWrite</a></li></ul><h3 style="font-size: 1.2em; font-family: Arial, Verdana, Helvetica, sans-serif; color: rgb(180, 162, 121); margin: 5px 0px; font-weight: normal;">Examples</h3><ul><li><a href="http://beagleboard.org/Support/BoneScript/cape_bacon/" style="color: rgb(222, 114, 36);">Bacon Cape</a></li></ul><div><br></div><div>This tutorial was made by Diego Turcios.</div><div>This tutorial is being modified by DiceTog. August 18, 2014. Time 20:25</div></div><div id="list" style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px;"></div>
<span style="font-weight: bold;">Function analogRead(pin,[callback])</span><br><br>A small explanation on how to use the analogRead function of the bonescript library.<br><img src="http://beagleboard.org/static/presentations/boston2011/beagleboard101/beagle.png" style="width: 320px;"><br>
Preview Card 1
Arguments
Build and execute instructions
Example Code
See Also
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment