Paul Langdon
Published

Example: Push Button

Sample Push Button on Intel Edison in Node.js

BeginnerProtip988
Example: Push Button

Story

Read more

Code

Read button and write state to console

JavaScript
// Load Grove module
var groveSensor = require('jsupm_grove');

// Create the button object using GPIO pin 0
var button = new groveSensor.GroveButton(0);

// Read the input and print, waiting one second between readings
function readButtonValue() {
    console.log(button.name() + " value is " + button.value());
}
setInterval(readButtonValue, 1000);

Credits

Paul Langdon
49 projects • 321 followers
Working as a cloud architect for an IoT hardware company
Contact

Comments

Please log in or sign up to comment.