2015-01-07 17:17:27 -08:00
|
|
|
/*
|
|
|
|
* Author: Sarah Knepper <sarah.knepper@intel.com>
|
|
|
|
* Copyright (c) 2015 Intel Corporation.
|
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* This program and the accompanying materials are made available under the
|
|
|
|
* terms of the The MIT License which is available at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
2015-01-07 17:17:27 -08:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2015-01-07 17:17:27 -08:00
|
|
|
*/
|
|
|
|
|
2016-11-03 10:55:07 +08:00
|
|
|
// Load UPM module
|
2016-09-12 16:16:30 -07:00
|
|
|
var ledSensor = require('jsupm_led');
|
2015-01-07 17:17:27 -08:00
|
|
|
|
2016-11-03 10:55:07 +08:00
|
|
|
// Create the LED object using GPIO pin 2
|
2016-09-12 16:16:30 -07:00
|
|
|
var led = new ledSensor.Led(2);
|
2015-01-07 17:17:27 -08:00
|
|
|
|
|
|
|
// Print the name
|
|
|
|
console.log(led.name());
|
|
|
|
|
|
|
|
// Turn the LED on and off 10 times, pausing one second
|
|
|
|
// between transitions
|
|
|
|
var i = 0;
|
|
|
|
var waiting = setInterval(function() {
|
|
|
|
if ( i % 2 == 0 ) {
|
|
|
|
led.on();
|
|
|
|
} else {
|
|
|
|
led.off();
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
if ( i == 20 ) clearInterval(waiting);
|
|
|
|
}, 1000);
|
|
|
|
|