Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 85 lines (52 sloc) 1.369 kb
d757f43 @rwaldron Update example programs docs files
authored
1 # Ir Proximity
2
3 Run with:
4 ```bash
5 node eg/ir-proximity.js
6 ```
7
8
9 ```javascript
10 var five = require("johnny-five");
11
12 five.Board().on("ready", function() {
13 // Create a new `IR.Proximity` hardware instance.
14 //
15 // five.IR.Proximity();
16 //
17 // (Alias of:
18 // new five.IR({
19 // device: "GP2Y0D805Z0F",
20 // freq: 50
21 // });
22 // )
23 //
24
25 var ir = new five.IR.Proximity();
26
27
28 // IR.Proximity Event API
29
30 // "motionstart"
31 //
32 // Fires when the proximal area is disrupted,
33 // generally by some form of movement
34
35 ir.on("motionstart", function() {
36
37 console.log( "motionstart" );
38
39 });
40
41 // "motionend"
42 //
43 // Fires when the proximal area is has been cleared
44 // of obstruction.
45
46 ir.on("motionend", function() {
47
48 console.log( "motionend" );
49
50 });
51
4b2cf07 @rwaldron Render doc examples
authored
52 // "data"
d757f43 @rwaldron Update example programs docs files
authored
53 //
54 // Fires continuously, every 66ms.
55 //
4b2cf07 @rwaldron Render doc examples
authored
56 ir.on("data", function( err, timestamp ) {
57 // console.log( "data" );
d757f43 @rwaldron Update example programs docs files
authored
58 });
59 });
60
61 ```
62
63
64
65
66
5e929ce @rwaldron Example program updates
authored
67
d757f43 @rwaldron Update example programs docs files
authored
68
69
70
71
72
73
74
75 ## Contributing
9558a90 @rwaldron Update docs files
authored
76 All contributions must adhere to the [Idiomatic.js Style Guide](https://github.com/rwldrn/idiomatic.js),
d757f43 @rwaldron Update example programs docs files
authored
77 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).
78
79 ## Release History
80 _(Nothing yet)_
81
82 ## License
83 Copyright (c) 2012 Rick Waldron <waldron.rick@gmail.com>
84 Licensed under the MIT license.
Something went wrong with that request. Please try again.