johnny-five
Version:
Firmata based Arduino Programming Framework.
78 lines (44 loc) • 1.46 kB
Markdown
Run with:
```bash
node eg/potentiometer.js
```
```javascript
var five = require("johnny-five"),
board, potentiometer;
board = new five.Board();
board.on("ready", function() {
// Create a new `potentiometer` hardware instance.
potentiometer = new five.Sensor({
pin: "A2",
freq: 250
});
// Inject the `sensor` hardware into
// the Repl instance's context;
// allows direct command line access
board.repl.inject({
pot: potentiometer
});
// "read" get the current reading from the potentiometer
potentiometer.on("read", function( err, value ) {
console.log( value, this.normalized );
});
});
// References
//
// http://arduino.cc/en/Tutorial/AnalogInput
```
<img src="https://raw.github.com/rwldrn/johnny-five/master/docs/breadboard/potentiometer.png">
[](https://github.com/rwldrn/johnny-five/blob/master/docs/breadboard/potentiometer.fzz)
_(Nothing yet)_
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).
_(Nothing yet)_
Copyright (c) 2012 Rick Waldron <waldron.rick@gmail.com>
Licensed under the MIT license.