-
Notifications
You must be signed in to change notification settings - Fork 1.8k
IR.Proximity
Rick Waldron edited this page Mar 22, 2023
·
10 revisions
The IR.Proximity
class constructs an object that represents a single Infrared Proximity sensor.
NOTE: The IR.Proximity
is deprecated. Please use the Proximity class.
-
options An object of property parameters.
Property Type Value/Description Default Required pin Number, String Analog Pin. The Number or String address of the pin the sensor is attached to, ie. 9, “D7” yes controller String "GP2Y0A21YK", "GP2D120XJ00F", "GP2Y0A02YK0F", "GP2Y0A41SK0F". The name of the controller to use yes
{
id: A user definable id value. Defaults to a generated uid
pin: The pin address that the Sensor is attached to
cm: Distance to obstruction in centimeters. READONLY
in: Distance to obstruction in inches. READONLY
}
new five.IR.Proximity({
controller: "GP2Y0A21YK",
pin: "A0"
});
var five = require("johnny-five");
var board = new five.Board();
var controller = process.argv[2] || "GP2Y0A02YK0F";
board.on("ready", function() {
var proximity = new five.IR.Proximity({
controller: controller,
pin: "A0"
});
proximity.on("data", function() {
console.log("inches: ", this.inches);
console.log("cm: ", this.cm);
});
});
-
data The "data" event is fired as frequently as the user defined freq will allow in milliseconds. ("data" replaced the "read" event)
-
change The "change" event is fired when the distance to obstruction reading changes within the observable range of the IR.Proximity sensor.