Created
November 25, 2014 05:02
-
-
Save w4ilun/6ed2976d71d8f48e760d to your computer and use it in GitHub Desktop.
Blink-IO.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var m = require('mraa'); //require mraa | |
console.log('MRAA Version: ' + m.getVersion()); //write the mraa version to the console | |
var myLed = new m.Gpio(13); //LED hooked up to digital pin 13 (or built in pin on Galileo Gen1 & Gen2) | |
myLed.dir(m.DIR_OUT); //set the gpio direction to output | |
var ledState = true; //Boolean to hold the state of Led | |
periodicActivity(); //call the periodicActivity function | |
function periodicActivity() | |
{ | |
myLed.write(ledState?1:0); //if ledState is true then write a '1' (high) otherwise write a '0' (low) | |
ledState = !ledState; //invert the ledState | |
setTimeout(periodicActivity,1000); //call the indicated function after 1 second (1000 milliseconds) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment