upm/examples/javascript/button.js
Mihai Tudor Panu 89d5de43e0 license: update to SPDX style license text throughout
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2020-03-05 15:13:36 -08:00

23 lines
637 B
JavaScript

/*
* Author: Sarah Knepper <sarah.knepper@intel.com>
* Copyright (c) 2014 Intel Corporation.
*
* 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.
*
* SPDX-License-Identifier: MIT
*/
// Load UPM module
var upm = require('jsupm_button');
// Create the button object using GPIO pin 0
var button = new upm.Button(0);
// Read the input and print, waiting one second between readings
function readButtonValue() {
console.log(button.name() + " value is " + button.value());
}
setInterval(readButtonValue, 1000);