Skip to content

Commit

Permalink
Motion: Support for GP2Y0D810Z0F & GP2Y0D815Z0F
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed May 21, 2015
1 parent 8f0fd12 commit 2dd715f
Show file tree
Hide file tree
Showing 13 changed files with 372 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ To interactively navigate the examples, visit the [Johnny-Five examples](http://
### Motion
- [Motion](https://github.com/rwaldron/johnny-five/blob/master/docs/motion.md)
- [Motion - GP2Y0D805Z0F](https://github.com/rwaldron/johnny-five/blob/master/docs/motion-gp2y0d805z0f.md)
- [Motion - GP2Y0D810Z0F](https://github.com/rwaldron/johnny-five/blob/master/docs/motion-gp2y0d810z0f.md)
- [Motion - GP2Y0D810Z0F](https://github.com/rwaldron/johnny-five/blob/master/docs/motion-gp2y0d815z0f.md)

### Joystick
- [Joystick](https://github.com/rwaldron/johnny-five/blob/master/docs/joystick.md)
Expand Down
Binary file added docs/breadboard/GP2Y0D810Z0F.fzz
Binary file not shown.
Binary file added docs/breadboard/GP2Y0D810Z0F.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/breadboard/PCF8574.fzz
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/motion-gp2y0d805z0f.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Motion - GP2Y0D805Z0F


Basic GP2Y0D805Z0F detection.
Basic GP2Y0D805Z0F motion detection.


Run with:
Expand Down
76 changes: 76 additions & 0 deletions docs/motion-gp2y0d810z0f.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!--remove-start-->

# Motion - GP2Y0D810Z0F



Run with:
```bash
node eg/motion-gp2y0d810z0f.js
```

<!--remove-end-->

```javascript
var five = require("johnny-five");
var board = new five.Board();

board.on("ready", function() {

// Create a new `motion` hardware instance.
var motion = new five.Motion({
controller: "GP2Y0D810Z0F",
pin: "A0"
});

// "calibrated" occurs once, at the beginning of a session,
motion.on("calibrated", function() {
console.log("calibrated");
});

// "motionstart" events are fired when the "calibrated"
// proximal area is disrupted, generally by some form of movement
motion.on("motionstart", function() {
console.log("motionstart");
});

// "motionend" events are fired following a "motionstart" event
// when no movement has occurred in X ms
motion.on("motionend", function() {
console.log("motionend");
});
});

```


## Illustrations / Photos


### Motion - GP2Y0D810Z0F


Basic GP2Y0D810Z0F motion detection.


![docs/breadboard/GP2Y0D810Z0F.png](breadboard/GP2Y0D810Z0F.png)<br>

Fritzing diagram: [docs/breadboard/GP2Y0D810Z0F.fzz](breadboard/GP2Y0D810Z0F.fzz)

&nbsp;





&nbsp;

<!--remove-start-->

## License
Copyright (c) 2012, 2013, 2014 Rick Waldron <waldron.rick@gmail.com>
Licensed under the MIT license.
Copyright (c) 2014, 2015 The Johnny-Five Contributors
Licensed under the MIT license.

<!--remove-end-->
76 changes: 76 additions & 0 deletions docs/motion-gp2y0d815z0f.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!--remove-start-->

# Motion - GP2Y0D810Z0F



Run with:
```bash
node eg/motion-gp2y0d815z0f.js
```

<!--remove-end-->

```javascript
var five = require("johnny-five");
var board = new five.Board();

board.on("ready", function() {

// Create a new `motion` hardware instance.
var motion = new five.Motion({
controller: "GP2Y0D810Z0F",
pin: "A0"
});

// "calibrated" occurs once, at the beginning of a session,
motion.on("calibrated", function() {
console.log("calibrated");
});

// "motionstart" events are fired when the "calibrated"
// proximal area is disrupted, generally by some form of movement
motion.on("motionstart", function() {
console.log("motionstart");
});

// "motionend" events are fired following a "motionstart" event
// when no movement has occurred in X ms
motion.on("motionend", function() {
console.log("motionend");
});
});

```


## Illustrations / Photos


### Motion - GP2Y0D815Z0F


Basic GP2Y0D815Z0F motion detection.


![docs/breadboard/GP2Y0D810Z0F.png](breadboard/GP2Y0D810Z0F.png)<br>

Fritzing diagram: [docs/breadboard/GP2Y0D810Z0F.fzz](breadboard/GP2Y0D810Z0F.fzz)

&nbsp;





&nbsp;

<!--remove-start-->

## License
Copyright (c) 2012, 2013, 2014 Rick Waldron <waldron.rick@gmail.com>
Licensed under the MIT license.
Copyright (c) 2014, 2015 The Johnny-Five Contributors
Licensed under the MIT license.

<!--remove-end-->
28 changes: 28 additions & 0 deletions eg/motion-gp2y0d810z0f.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var five = require("../lib/johnny-five.js");
var board = new five.Board();

board.on("ready", function() {

// Create a new `motion` hardware instance.
var motion = new five.Motion({
controller: "GP2Y0D810Z0F",
pin: "A0"
});

// "calibrated" occurs once, at the beginning of a session,
motion.on("calibrated", function() {
console.log("calibrated");
});

// "motionstart" events are fired when the "calibrated"
// proximal area is disrupted, generally by some form of movement
motion.on("motionstart", function() {
console.log("motionstart");
});

// "motionend" events are fired following a "motionstart" event
// when no movement has occurred in X ms
motion.on("motionend", function() {
console.log("motionend");
});
});
28 changes: 28 additions & 0 deletions eg/motion-gp2y0d815z0f.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var five = require("../lib/johnny-five.js");
var board = new five.Board();

board.on("ready", function() {

// Create a new `motion` hardware instance.
var motion = new five.Motion({
controller: "GP2Y0D810Z0F",
pin: "A0"
});

// "calibrated" occurs once, at the beginning of a session,
motion.on("calibrated", function() {
console.log("calibrated");
});

// "motionstart" events are fired when the "calibrated"
// proximal area is disrupted, generally by some form of movement
motion.on("motionstart", function() {
console.log("motionstart");
});

// "motionend" events are fired following a "motionstart" event
// when no movement has occurred in X ms
motion.on("motionend", function() {
console.log("motionend");
});
});
28 changes: 27 additions & 1 deletion lib/motion.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,40 @@ var Controllers = {
return raw === 0;
}
}
},
GP2Y0D810Z0F: {
initialize: {
value: function(opts, dataHandler) {
var state = priv.get(this);

this.io.pinMode(opts.pin, this.io.MODES.ANALOG);

setTimeout(function() {
state.isCalibrated = true;
this.emit("calibrated");
}.bind(this), 10);

this.io.analogRead(opts.pin, dataHandler);
}
},
toBoolean: {
value: function(raw) {
return raw >> 9 === 0;
}
}
}
};

Controllers.GP2Y0D815Z0F = Controllers.GP2Y0D810Z0F;

Controllers["HC-SR501"] = Controllers.PIR;
Controllers["HCSR501"] = Controllers.PIR;
Controllers["0D805"] = Controllers.GP2Y0D805Z0F;
Controllers["805"] = Controllers.GP2Y0D805Z0F;

Controllers["0D810"] = Controllers.GP2Y0D810Z0F;
Controllers["810"] = Controllers.GP2Y0D810Z0F;
Controllers["0D815"] = Controllers.GP2Y0D815Z0F;
Controllers["815"] = Controllers.GP2Y0D815Z0F;

/**
* Motion
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "johnny-five",
"description": "The JavaScript Hardware Programming Framework. Use with: Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, Raspberry Pi, Spark Core, TI Launchpad and more!",
"description": "The JavaScript Robotics and Hardware Programming Framework. Use with: Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, Raspberry Pi, Spark Core, TI Launchpad and more!",
"version": "0.8.74",
"homepage": "https://github.com/rwaldron/johnny-five",
"homepage": "https://johnny-five.io",
"author": {
"name": "Rick Waldron <waldron.rick@gmail.com>",
"email": "waldron.rick@gmail.com"
Expand Down
Loading

0 comments on commit 2dd715f

Please sign in to comment.