-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #688 from frxnz/proximity-refactor
Consolidate all the proximity/ranging devices. Closes #688.
- Loading branch information
Showing
22 changed files
with
927 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
| ||
|
||
|
||
|
||
|
||
|
||
| ||
|
||
<!--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--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
| ||
|
||
|
||
|
||
|
||
|
||
| ||
|
||
<!--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--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
| ||
|
||
|
||
|
||
|
||
|
||
| ||
|
||
<!--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--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
| ||
|
||
|
||
|
||
|
||
|
||
| ||
|
||
<!--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--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
}); | ||
|
||
}); |
Oops, something went wrong.