johnny-five
Version:
The JavaScript Arduino Programming Framework.
67 lines (39 loc) • 1.32 kB
Markdown
Run with:
```bash
node eg/button-pullup.js
```
```javascript
// The `isPullup` button option enables the pullup
// resistor on the pin and automatically sets the
// `invert` option to true
// In this circuit configuration, the LED would always
// be on without the pullup resistor enabled
// For more info on pullup resistors, see:
// http://arduino.cc/en/Tutorial/InputPullupSerial
// http://arduino.cc/en/Tutorial/DigitalPins
// https://learn.sparkfun.com/tutorials/pull-up-resistors
var five = require("../lib/johnny-five"),
button, led;
five.Board().on("ready", function() {
button = new five.Button({
pin: 2,
isPullup: true
});
led = new five.Led(13);
button.on("down", function(value) {
led.on();
});
button.on("up", function() {
led.off();
});
});
```

All contributions must adhere to the [Idiomatic.js Style Guide](https://github.com/rwldrn/idiomatic.js),
by maintaining the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt](https://github.com/cowboy/grunt).
Copyright (c) 2012 Rick Waldron <waldron.rick@gmail.com>
Licensed under the MIT license.