Skip to content

Instantly share code, notes, and snippets.

@DiegoTc
Created July 17, 2014 02:36
Show Gist options
  • Save DiegoTc/786401651ca972197345 to your computer and use it in GitHub Desktop.
Save DiegoTc/786401651ca972197345 to your computer and use it in GitHub Desktop.
Bone101 Tutorial
<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><div><ul style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px;"><li>Connect the cathode side of the LED with a 470 ohm resistor in series, then to ground.</li><li>Connect the anode side of the LED to 'P8_13.'</li><li>Connect one side of the push-button to P'9_3' and the other to 'P8_19.'</li><li>Run the example code. If the push button is pressed, it will turn the LED on</li></ul></div><div><span style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px;"><img src="http://beagleboard.org/static/uploads/pushbutton.PNG" style="width: 403px;"><br></span></div>
var b = require('bonescript');
b.pinMode('P8_19', b.INPUT);
b.pinMode('P8_13', b.OUTPUT);
setInterval(check,100);
function check(){
b.digitalRead('P8_19', checkButton);
}
function checkButton(x) {
if(x.value == 1){
b.digitalWrite('P8_13', b.HIGH);
}
else{
b.digitalWrite('P8_13', b.LOW);
}
}
<span style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px;">Every second, the program will check if the user has pressed the push button. If the push button is pressed, it will turn the LED on.<br></span><div><span style="color: rgb(82, 82, 82); font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px;"><img src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTAnMYUq4daQOCaCOrTR5yVGTcVTS3n1CFCYbBwHvjEmsBIMM6h" style="width: 243px;"><br></span></div>
Preview Card 1
Build and execute instructions
Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment