johnny-five
Version:
The JavaScript Arduino Programming Framework.
65 lines (39 loc) • 1.27 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
});
// "data" get the current reading from the potentiometer
potentiometer.on("data", function() {
console.log(this.value, this.raw);
});
});
// References
//
// http://arduino.cc/en/Tutorial/AnalogInput
```

[](breadboard/potentiometer.fzz)
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).
Copyright (c) 2012 Rick Waldron <waldron.rick@gmail.com>
Licensed under the MIT license.