Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 88 lines (53 sloc) 1.594 kb
6b5ab5b @rwaldron Rebuild all example program markdown files
authored
1 # Button Options
2
3 Run with:
4 ```bash
5 node eg/button-options.js
6 ```
7
8
9 ```javascript
10 var five = require("johnny-five"),
11 board, button;
12
13 board = new five.Board();
14
15 board.on("ready", function() {
16
17 // Create a new `button` hardware instance
18 button = new five.Button({
19 board: board,
20 pin: 7,
21 holdtime: 1000
22 });
23
24 // Inject the `button` hardware into
25 // the Repl instance's context;
26 // allows direct command line access
27 board.repl.inject({
28 button: button
29 });
30
31 // Button Event API
32
33 // "down" the button is pressed
34 button.on("down", function() {
35 console.log("down");
36 });
37
38 // "hold" the button is pressed for specified time.
39 // defaults to 500ms (1/2 second)
40 // set
41 button.on("hold", function() {
42 console.log("hold");
43 });
44
45 // "up" the button is released
46 button.on("up", function() {
47 console.log("up");
48 });
49 });
50
51 ```
52
53 ## Breadboard
54
55 <img src="https://raw.github.com/rwldrn/johnny-five/master/docs/breadboard/button-options.png">
56
57 [button-options.fzz](https://github.com/rwldrn/johnny-five/blob/master/docs/breadboard/button-options.fzz)
58
59
5e929ce @rwaldron Example program updates
authored
60
61 ## Devices
62
63
64
65
6b5ab5b @rwaldron Rebuild all example program markdown files
authored
66 ## Documentation
67
68 _(Nothing yet)_
69
70
71
72
73
74
75
76
77
78 ## Contributing
9558a90 @rwaldron Update docs files
authored
79 All contributions must adhere to the [Idiomatic.js Style Guide](https://github.com/rwldrn/idiomatic.js),
6b5ab5b @rwaldron Rebuild all example program markdown files
authored
80 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).
81
82 ## Release History
83 _(Nothing yet)_
84
85 ## License
86 Copyright (c) 2012 Rick Waldron <waldron.rick@gmail.com>
87 Licensed under the MIT license.
Something went wrong with that request. Please try again.