2014-04-22 15:51:28 +01:00
|
|
|
/*
|
2014-08-14 15:16:23 -04:00
|
|
|
* Author: Dan Yocom <dan.yocom@intel.com>
|
2014-04-22 15:51:28 +01:00
|
|
|
* Copyright (c) 2014 Intel Corporation.
|
|
|
|
|
*
|
2019-05-09 09:47:11 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2014-04-22 15:51:28 +01:00
|
|
|
*/
|
|
|
|
|
|
2017-02-23 00:57:19 -06:00
|
|
|
"use strict";
|
2014-04-08 18:43:26 +01:00
|
|
|
|
2017-02-23 00:57:19 -06:00
|
|
|
const mraa = require('mraa'); //require mraa
|
|
|
|
|
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console
|
2014-08-14 15:16:23 -04:00
|
|
|
|
2017-02-23 00:57:19 -06:00
|
|
|
let myLed = new mraa.Gpio(13); //LED hooked up to digital pin 13 (or built in pin on Galileo Gen1 & Gen2)
|
|
|
|
|
myLed.dir(mraa.DIR_OUT); //set the gpio direction to output
|
|
|
|
|
let ledState = true; //Boolean to hold the state of Led
|
2016-01-06 16:37:14 +00:00
|
|
|
|
2017-02-23 00:57:19 -06:00
|
|
|
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
|
|
|
|
|
}
|
2016-01-06 16:37:14 +00:00
|
|
|
|
2017-02-23 00:57:19 -06:00
|
|
|
setInterval(periodicActivity, 1000); //call the periodicActivity function every second
|