Skip to content
Newer
Older
100644 88 lines (53 sloc) 1.58 KB
6b5ab5b @rwaldron Rebuild all example program markdown files
authored Jul 2, 2012
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
1b7af18 @rwaldron Change "Breadboard" heading to "Breadboard/Illustration"
authored Apr 29, 2013
53 ## Breadboard/Illustration
6b5ab5b @rwaldron Rebuild all example program markdown files
authored Jul 2, 2012
54
55 <img src="https://raw.github.com/rwldrn/johnny-five/master/docs/breadboard/button-options.png">
56
bd26733 @rwaldron Re-render all allowed example programs. Fixes gh-65
authored Aug 29, 2012
57 [docs/breadboard/button-options.fzz](https://github.com/rwldrn/johnny-five/blob/master/docs/breadboard/button-options.fzz)
6b5ab5b @rwaldron Rebuild all example program markdown files
authored Jul 2, 2012
58
59
5e929ce @rwaldron Example program updates
authored Aug 15, 2012
60
61 ## Devices
62
63
64
65
6b5ab5b @rwaldron Rebuild all example program markdown files
authored Jul 2, 2012
66 ## Documentation
67
68 _(Nothing yet)_
69
70
71
72
73
74
75
76
77
78 ## Contributing
9558a90 @rwaldron Update docs files
authored Aug 19, 2012
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 Jul 2, 2012
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.