Skip to content

Instantly share code, notes, and snippets.

@DiegoTc
Last active August 29, 2015 14:04
Show Gist options
  • Save DiegoTc/eac17d013b3a7c335a19 to your computer and use it in GitHub Desktop.
Save DiegoTc/eac17d013b3a7c335a19 to your computer and use it in GitHub Desktop.
Bone101 Tutorial
<p style="font-size: 1.1em; line-height: 1.3em; color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif;">Write a&nbsp;<a href="http://beagleboard.org/Support/BoneScript/#HIGH" style="color: rgb(222, 114, 36);">HIGH</a>&nbsp;or&nbsp;<a href="http://beagleboard.org/Support/BoneScript/#LOW" style="color: rgb(222, 114, 36);">LOW</a>&nbsp;to a digital I/O pin.</p><p style="font-size: 1.1em; line-height: 1.3em; color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif;">NOTE: The 4 USRx LEDs are all able to operate as digital output pins, giving you an always-available output to test your software.</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);">BeagleBone pin</a>&nbsp;identifier</li><li><em>value</em>: the logic level to set the pin</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><a href="http://beagleboard.org/Support/BoneScript/#true" style="color: rgb(222, 114, 36);">true</a>&nbsp;if successful</li><li><a href="http://beagleboard.org/Support/BoneScript/#false" style="color: rgb(222, 114, 36);">false</a>&nbsp;on failure</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.err</em>: error status message</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;">Build and execute instructions</h2><h2 style="font-size: 1.5em; font-family: Arial, Verdana, Helvetica, sans-serif; color: rgb(180, 162, 121); margin: 5px 0px; line-height: normal;"><img align="right" width="50%" src="http://beagleboard.org/static/uploads/LEDs.PNG" style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px;"><ul style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px;"><li>The USR0 LED is built in, so no circuit assembly is required.</li><li>Look for it to go high when you run the example code.</li><li>Alter the code to set it low and run it again.</li></ul></h2>
var b = require('bonescript');
b.pinMode('USR0', b.OUTPUT);
b.digitalWrite('USR0', b.HIGH);
var b = require('bonescript');
b.pinMode('USR0', b.OUTPUT);
b.digitalWrite('USR0', b.LOW);
<span style="font-weight: bold;">digitalWrite(pin, value, [callback])</span><div>The digitalWrite function, writes a HIGH or LOW to a digital I/O pin.</div><div><img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ5RIqUaRRNmT801sTv6rf-cwpz9qfzj5w4XEzR2YaUsJajXmRN" style="width: 80px;"><br></div>
Preview Card 1
Explanation
Build and execute instructions
Example High
Example Low
var b = require('bonescript');
b.pinMode('USR0', b.OUTPUT);
b.digitalWrite('USR0', b.HIGH);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment