Skip to content

Commit

Permalink
Merge pull request #688 from frxnz/proximity-refactor
Browse files Browse the repository at this point in the history
Consolidate all the proximity/ranging devices. Closes #688.
  • Loading branch information
derekwheee committed Apr 29, 2015
2 parents e355434 + e70eba0 commit 310cdd1
Show file tree
Hide file tree
Showing 22 changed files with 927 additions and 60 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@ To interactively navigate the examples, visit the [Johnny-Five examples](http://
- [IR Reflectance](https://github.com/rwaldron/johnny-five/blob/master/docs/ir-reflect.md)
- [IR Reflectance Array](https://github.com/rwaldron/johnny-five/blob/master/docs/ir-reflect-array.md)

### Proximity
- [Proximity](https://github.com/rwaldron/johnny-five/blob/master/docs/proximity.md)
- [Proximity - SRF10](https://github.com/rwaldron/johnny-five/blob/master/docs/proximity-srf10.md)
- [Proximity - MB1003](https://github.com/rwaldron/johnny-five/blob/master/docs/proximity-mb1003.md)
- [Proximity - HC-SR04](https://github.com/rwaldron/johnny-five/blob/master/docs/proximity-hcsr04.md)

### Joystick
- [Joystick](https://github.com/rwaldron/johnny-five/blob/master/docs/joystick.md)
- [Joystick - Claw control](https://github.com/rwaldron/johnny-five/blob/master/docs/joystick-claw.md)
Expand Down
Binary file added docs/breadboard/proximity-hcsr04.fzz
Binary file not shown.
Binary file added docs/breadboard/proximity-hcsr04.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/proximity-mb1003.fzz
Binary file not shown.
Binary file added docs/breadboard/proximity-mb1003.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/proximity-srf10.fzz
Binary file not shown.
Binary file added docs/breadboard/proximity-srf10.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/proximity.fzz
Binary file not shown.
Binary file added docs/breadboard/proximity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions docs/proximity-hcsr04.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!--remove-start-->

# Proximity - HC-SR04


Basic ping Proximity example with HC-SR04 sensor.


Run with:
```bash
node eg/proximity-hcsr04.js
```

<!--remove-end-->

```javascript
var five = require("johnny-five");

five.Board().on("ready", function() {

var proximity = new five.Proximity({
controller: "HCSR04",
pin: 7
});

proximity.on("data", function(data) {
console.log(data.cm + "cm", data.in + "in");
});

proximity.on("change", function(data) {
console.log("The obstruction has moved.");
});

});

```


## Illustrations / Photos


### Breadboard for "Proximity - HC-SR04"



![docs/breadboard/proximity-hcsr04.png](breadboard/proximity-hcsr04.png)<br>

Fritzing diagram: [docs/breadboard/proximity-hcsr04.fzz](breadboard/proximity-hcsr04.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-->
66 changes: 66 additions & 0 deletions docs/proximity-mb1003.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!--remove-start-->

# Proximity - MB1003


Basic sonar Proximity example with MB1003 sensor.


Run with:
```bash
node eg/proximity-mb1003.js
```

<!--remove-end-->

```javascript
var five = require("johnny-five");

five.Board().on("ready", function() {

var proximity = new five.Proximity({
controller: "MB1003",
pin: "A0"
});

proximity.on("data", function(data) {
console.log(data.cm + "cm", data.in + "in");
});

proximity.on("change", function(data) {
console.log("The obstruction has moved.");
});

});

```


## Illustrations / Photos


### Breadboard for "Proximity - MB1003"



![docs/breadboard/proximity-mb1003.png](breadboard/proximity-mb1003.png)<br>

Fritzing diagram: [docs/breadboard/proximity-mb1003.fzz](breadboard/proximity-mb1003.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-->
65 changes: 65 additions & 0 deletions docs/proximity-srf10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!--remove-start-->

# Proximity - SRF10


Basic sonar Proximity example with SRF10 sensor.


Run with:
```bash
node eg/proximity-srf10.js
```

<!--remove-end-->

```javascript
var five = require("johnny-five");

five.Board().on("ready", function() {

var proximity = new five.Proximity({
controller: "SRF10"
});

proximity.on("data", function(data) {
console.log(data.cm + "cm", data.in + "in");
});

proximity.on("change", function(data) {
console.log("The obstruction has moved.");
});

});

```


## Illustrations / Photos


### Breadboard for "Proximity - SRF10"



![docs/breadboard/proximity-srf10.png](breadboard/proximity-srf10.png)<br>

Fritzing diagram: [docs/breadboard/proximity-srf10.fzz](breadboard/proximity-srf10.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-->
66 changes: 66 additions & 0 deletions docs/proximity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!--remove-start-->

# Proximity


Basic infrared Proximity example


Run with:
```bash
node eg/proximity.js
```

<!--remove-end-->

```javascript
var five = require("johnny-five");

five.Board().on("ready", function() {

var proximity = new five.Proximity({
controller: "GP2Y0A21YK",
pin: "A0"
});

proximity.on("data", function(data) {
console.log(data.cm + "cm", data.in + "in");
});

proximity.on("change", function(data) {
console.log("The obstruction has moved.");
});

});

```


## Illustrations / Photos


### Breadboard for "Proximity"



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

Fritzing diagram: [docs/breadboard/proximity.fzz](breadboard/proximity.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-->
18 changes: 18 additions & 0 deletions eg/proximity-hcsr04.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var five = require("../lib/johnny-five.js");

five.Board().on("ready", function() {

var proximity = new five.Proximity({
controller: "HCSR04",
pin: 7
});

proximity.on("data", function(data) {
console.log(data.cm + "cm", data.in + "in");
});

proximity.on("change", function(data) {
console.log("The obstruction has moved.");
});

});
18 changes: 18 additions & 0 deletions eg/proximity-mb1003.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var five = require("../lib/johnny-five.js");

five.Board().on("ready", function() {

var proximity = new five.Proximity({
controller: "MB1003",
pin: "A0"
});

proximity.on("data", function(data) {
console.log(data.cm + "cm", data.in + "in");
});

proximity.on("change", function(data) {
console.log("The obstruction has moved.");
});

});
17 changes: 17 additions & 0 deletions eg/proximity-srf10.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var five = require("../lib/johnny-five.js");

five.Board().on("ready", function() {

var proximity = new five.Proximity({
controller: "SRF10"
});

proximity.on("data", function(data) {
console.log(data.cm + "cm", data.in + "in");
});

proximity.on("change", function(data) {
console.log("The obstruction has moved.");
});

});
51 changes: 9 additions & 42 deletions eg/proximity.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,18 @@
var five = require("../lib/johnny-five.js"),
prox, led;
var five = require("../lib/johnny-five.js");

five.Board().on("ready", function() {

// Create a new IR Proximity Sensor hardware instance.
//
// five.IR.Proximity();
//
// (Alias of:
// new five.IR({
// device: "GP2Y0D805Z0F",
// freq: 50
// });
// )
//

prox = new five.IR.Proximity();
led = new five.Led(13);





// Properties

// prox.state
//

// Proximity Event API

// "motionstart"
//
// Fired motion is detected with 2"
//

var proximity = new five.Proximity({
controller: "GP2Y0A21YK",
pin: "A0"
});

// "motionend"
//
// Fired following a "motionstart" event
// when no movement has occurred in X ms
//
prox.on("motionstart", function(err, timestamp) {
led.on();
proximity.on("data", function(data) {
console.log(data.cm + "cm", data.in + "in");
});

prox.on("motionend", function(err, timestamp) {
led.off();
proximity.on("change", function(data) {
console.log("The obstruction has moved.");
});

});
Loading

0 comments on commit 310cdd1

Please sign in to comment.