UNPKG

johnny-five

Version:

Firmata based Arduino Programming Framework.

105 lines (66 loc) 1.75 kB
# Sensor Run with: ```bash node eg/sensor.js ``` ```javascript var five = require("johnny-five"), board, sensor; board = new five.Board(); board.on("ready", function() { // Create a new `sensor` hardware instance. sensor = new five.Sensor({ pin: "A0", freq: 250 }); // Inject the `sensor` hardware into // the Repl instance's context; // allows direct command line access board.repl.inject({ sensor: sensor }); // Properties // sensor.normalized // // Current value of a sensor 0-255 // // sensor.scaled // // Current value of a sensor, scaled to a value // between the lower and upper bound set by calling // scale( low, high ). // // Defaults to value between 0-255 // // Sensor Event API // "read" // // Fires when the pin is read for a value // sensor.scale([ 0, 100 ]).on("read", function() { console.log( this.normalized, this.scaled ); }); // "change" // // Aliases: "bend", "force", "slide", "touch" // // Fires when value of sensor changes // }); // Tutorials // // http://protolab.pbworks.com/w/page/19403657/TutorialSensors // http://www.dfrobot.com/wiki/index.php?title=Analog_Slide_Position_Sensor_(SKU:_DFR0053) ``` ## Breadboard/Illustration ## Devices ## Documentation _(Nothing yet)_ ## Contributing All contributions must adhere to the [Idiomatic.js Style Guide](https://github.com/rwldrn/idiomatic.js), 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). ## Release History _(Nothing yet)_ ## License Copyright (c) 2012 Rick Waldron <waldron.rick@gmail.com> Licensed under the MIT license.