Skip to content

Instantly share code, notes, and snippets.

@w4ilun
Created November 25, 2014 05:02
Show Gist options
  • Save w4ilun/6ed2976d71d8f48e760d to your computer and use it in GitHub Desktop.
Save w4ilun/6ed2976d71d8f48e760d to your computer and use it in GitHub Desktop.
Blink-IO.js
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