Skip to content
Browse files

Rebuild all example program markdown files

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information...
1 parent 462ec64 commit 6b5ab5b6950342f50209abb7e7d2036a80c925e3 @rwaldron committed Jul 2, 2012
Showing with 5,957 additions and 2 deletions.
  1. +2 −2 README.md
  2. +80 −0 docs/accelerometer-pan-tilt.md
  3. +84 −0 docs/accelerometer.md
  4. +63 −0 docs/board-multi.md
  5. +72 −0 docs/board.md
  6. +283 −0 docs/boe-test-servos.md
  7. +81 −0 docs/button-options.md
  8. +79 −0 docs/button.md
  9. +76 −0 docs/claw.md
  10. +81 −0 docs/continuous-clock.md
  11. +72 −0 docs/continuous.md
  12. +135 −0 docs/hmc5883l.md
  13. +99 −0 docs/ir.md
  14. +66 −0 docs/joystick-claw.md
  15. +79 −0 docs/joystick-laser.md
  16. +109 −0 docs/joystick-motor-led.md
  17. +97 −0 docs/joystick.md
  18. +52 −0 docs/laser.md
  19. +59 −0 docs/lcd.md
  20. +80 −0 docs/led-fade.md
  21. +66 −0 docs/led-on-off.md
  22. +76 −0 docs/led-pulse.md
  23. +56 −0 docs/led-rgb.md
  24. +54 −0 docs/led-strobe.md
  25. +146 −0 docs/magnetometer-log.md
  26. +150 −0 docs/magnetometer-north.md
  27. +108 −0 docs/magnetometer.md
  28. +89 −0 docs/motor.md
  29. +108 −0 docs/navigator-joystick.md
  30. +479 −0 docs/navigator-original.md
  31. +526 −0 docs/navigator.md
  32. +65 −0 docs/piezo.md
  33. +82 −0 docs/ping.md
  34. +79 −0 docs/pir.md
  35. +71 −0 docs/potentiometer.md
  36. +90 −0 docs/proximity.md
  37. +309 −0 docs/radar-client.md
  38. +168 −0 docs/radar.md
  39. +49 −0 docs/repl.md
  40. +60 −0 docs/sensor-fsr-servo.md
  41. +63 −0 docs/sensor-fsr.md
  42. +69 −0 docs/sensor-ir-led-receiver.md
  43. +76 −0 docs/sensor-slider.md
  44. +98 −0 docs/sensor.md
  45. +117 −0 docs/servo-array.md
  46. +96 −0 docs/servo-diagnostic.md
  47. +75 −0 docs/servo-digital.md
  48. +75 −0 docs/servo-dual.md
  49. +67 −0 docs/servo-tutorial.md
  50. +112 −0 docs/servo.md
  51. +62 −0 docs/slider-log.md
  52. +68 −0 docs/slider-pan.md
  53. +69 −0 docs/slider-servo-control.md
  54. +59 −0 docs/socket.md
  55. +180 −0 docs/sonar-scan.md
  56. +91 −0 docs/sonar.md
View
4 README.md
@@ -97,19 +97,19 @@ board.on("ready", function() {
- [Led Pulse](https://github.com/rwldrn/johnny-five/blob/master/docs/led-pulse.md)
- [Led Rgb](https://github.com/rwldrn/johnny-five/blob/master/docs/led-rgb.md)
- [Led Strobe](https://github.com/rwldrn/johnny-five/blob/master/docs/led-strobe.md)
+- [Magnetometer Log](https://github.com/rwldrn/johnny-five/blob/master/docs/magnetometer-log.md)
- [Magnetometer North](https://github.com/rwldrn/johnny-five/blob/master/docs/magnetometer-north.md)
-- [Magnetometer Servo](https://github.com/rwldrn/johnny-five/blob/master/docs/magnetometer-servo.md)
- [Magnetometer](https://github.com/rwldrn/johnny-five/blob/master/docs/magnetometer.md)
- [Motor](https://github.com/rwldrn/johnny-five/blob/master/docs/motor.md)
- [Navigator Joystick](https://github.com/rwldrn/johnny-five/blob/master/docs/navigator-joystick.md)
- [Navigator Original](https://github.com/rwldrn/johnny-five/blob/master/docs/navigator-original.md)
- [Navigator](https://github.com/rwldrn/johnny-five/blob/master/docs/navigator.md)
- [Piezo](https://github.com/rwldrn/johnny-five/blob/master/docs/piezo.md)
-- [Ping Radar](https://github.com/rwldrn/johnny-five/blob/master/docs/ping-radar.md)
- [Ping](https://github.com/rwldrn/johnny-five/blob/master/docs/ping.md)
- [Pir](https://github.com/rwldrn/johnny-five/blob/master/docs/pir.md)
- [Potentiometer](https://github.com/rwldrn/johnny-five/blob/master/docs/potentiometer.md)
- [Proximity](https://github.com/rwldrn/johnny-five/blob/master/docs/proximity.md)
+- [Radar Client](https://github.com/rwldrn/johnny-five/blob/master/docs/radar-client.md)
- [Radar](https://github.com/rwldrn/johnny-five/blob/master/docs/radar.md)
- [Repl](https://github.com/rwldrn/johnny-five/blob/master/docs/repl.md)
- [Sensor Fsr Servo](https://github.com/rwldrn/johnny-five/blob/master/docs/sensor-fsr-servo.md)
View
80 docs/accelerometer-pan-tilt.md
@@ -0,0 +1,80 @@
+# Accelerometer Pan Tilt
+
+Run with:
+```bash
+node eg/accelerometer-pan-tilt.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ var range, pan, tilt, accel;
+
+ range = [ 0, 170 ];
+
+ // Servo to control panning
+ pan = new five.Servo({
+ pin: 9,
+ range: range
+ });
+
+ // Servo to control tilt
+ tilt = new five.Servo({
+ pin: 10,
+ range: range
+ });
+
+ // Accelerometer to control pan/tilt
+ accel = new five.Accelerometer({
+ pins: [ "A3", "A4", "A5" ],
+ freq: 250
+ });
+
+ // Center all servos
+ (five.Servos()).center();
+
+ accel.on("acceleration", function( err, timestamp ) {
+ // console.log( "acceleration", this.axis );
+
+ tilt.move( Math.abs( Math.ceil(170 * this.pitch.toFixed(2)) - 180 ) );
+ pan.move( Math.ceil(170 * this.roll.toFixed(2)) );
+
+ // TODO: Math.abs(v - 180) as inversion function ?
+ });
+});
+
+```
+
+## Breadboard
+
+
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
84 docs/accelerometer.md
@@ -0,0 +1,84 @@
+# Accelerometer
+
+Run with:
+```bash
+node eg/accelerometer.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board, accel;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ // Create a new `Accelerometer` hardware instance.
+ //
+ // five.Accelerometer([ x, y[, z] ]);
+ //
+ // five.Accelerometer({
+ // pins: [ x, y[, z] ]
+ // freq: ms
+ // });
+ //
+
+ accel = new five.Accelerometer({
+ pins: [ "A3", "A4", "A5" ],
+ freq: 100
+ });
+
+ // Accelerometer Event API
+
+ // "acceleration"
+ //
+ // Fires once every N ms, equal to value of freg
+ // Defaults to 500ms
+ //
+ accel.on("acceleration", function( err, timestamp ) {
+
+ console.log( "acceleration", this.pitch, this.roll );
+ });
+
+ // "axischange"
+ //
+ // Fires only when X, Y or Z has changed
+ //
+ accel.on("axischange", function( err, timestamp ) {
+
+ console.log( "axischange", this.raw );
+ });
+});
+
+```
+
+## Breadboard
+
+<img src="https://raw.github.com/rwldrn/johnny-five/master/docs/breadboard/accelerometer.png">
+
+[accelerometer.fzz](https://github.com/rwldrn/johnny-five/blob/master/docs/breadboard/accelerometer.fzz)
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
63 docs/board-multi.md
@@ -0,0 +1,63 @@
+# Board Multi
+
+Run with:
+```bash
+node eg/board-multi.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ boards;
+
+boards = [
+ new five.Board({ id: "a" }),
+ new five.Board({ id: "b" })
+];
+
+// Add ready event handlers to both boards.
+boards.forEach(function( board ) {
+ board.on("ready", function() {
+ var val = 0;
+
+ console.log( "ready!!!!!" );
+
+ // Set pin 13 to OUTPUT mode
+ this.pinMode( 13, 1 );
+
+ // Create a loop to "flash/blink/strobe" an led
+ this.loop( 50, function() {
+ this.digitalWrite( 13, (val = val ? 0 : 1) );
+ });
+ });
+});
+
+```
+
+## Breadboard
+
+
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
72 docs/board.md
@@ -0,0 +1,72 @@
+# Board
+
+Run with:
+```bash
+node eg/board.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board;
+
+board = new five.Board();
+
+// The board's pins will not be accessible until
+// the board has reported that it is ready
+board.on("ready", function() {
+ var val = 0;
+
+ // Set pin 13 to OUTPUT mode
+ this.pinMode( 13, 1 );
+
+ // Mode Table
+ // INPUT: 0
+ // OUTPUT: 1
+ // ANALOG: 2
+ // PWM: 3
+ // SERVO: 4
+
+ // Create a loop to "flash/blink/strobe" an led
+ this.loop( 50, function() {
+
+ this.digitalWrite( 13, (val = val ? 0 : 1) );
+
+ });
+});
+
+
+// Schematic
+// http://arduino.cc/en/uploads/Tutorial/ExampleCircuit_bb.png
+
+```
+
+## Breadboard
+
+<img src="https://raw.github.com/rwldrn/johnny-five/master/docs/breadboard/board.png">
+
+[board.fzz](https://github.com/rwldrn/johnny-five/blob/master/docs/breadboard/board.fzz)
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
283 docs/boe-test-servos.md
@@ -0,0 +1,283 @@
+# Boe Test Servos
+
+Run with:
+```bash
+node eg/boe-test-servos.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board, Navigator, bot, left, right, sonar, scanner, servos,
+ expandWhich, reverseDirMap, scale;
+
+reverseDirMap = {
+ right: "left",
+ left: "right"
+};
+
+scale = function( speed, low, high ) {
+ return Math.floor( five.Fn.map( speed, 0, 5, low, high ) );
+};
+
+
+/**
+ * Navigator
+ * @param {Object} opts Optional properties object
+ */
+function Navigator( opts ) {
+
+ // Boe Navigator continuous are calibrated to stop at 90°
+ this.center = opts.center || 90;
+
+ this.servos = {
+ right: new five.Servo({ pin: opts.right, type: "continuous" }),
+ left: new five.Servo({ pin: opts.left, type: "continuous" })
+ };
+
+ this.direction = opts.direction || {
+ right: this.center,
+ left: this.center
+ };
+
+ this.speed = opts.speed == null ? 0 : opts.speed;
+
+ this.history = [];
+ this.which = "forward";
+ this.isTurning = false;
+
+ setTimeout(function() {
+ this.fwd(1).fwd(0);
+ }.bind(this), 10);
+}
+
+/**
+ * move
+ * @param {Number} right Speed/Direction of right servo
+ * @param {Number} left Speed/Direction of left servo
+ * @return {Object} this
+ */
+Navigator.prototype.move = function( right, left ) {
+
+ // Quietly ignore duplicate instructions
+ if ( this.direction.right === right &&
+ this.direction.left === left ) {
+ return this;
+ }
+
+ // Servos are mounted opposite of each other,
+ // the values for left and right will be in
+ // opposing directions.
+ this.servos.right.move( right );
+ this.servos.left.move( left );
+
+ // Store a recallable history of movement
+ this.history.push({
+ timestamp: Date.now(),
+ right: right,
+ left: left
+ });
+
+ // Update the stored direction state
+ this.direction.right = right;
+ this.direction.left = left;
+
+ return this;
+};
+
+
+// TODO: DRY OUT!!!!!!!
+
+
+/**
+ * forward Move the bot forward
+ * fwd Move the bot forward
+ *
+ * @param {Number}0-5, 0 is stopped, 5 is fastest
+ * @return {Object} this
+ */
+Navigator.prototype.forward = Navigator.prototype.fwd = function( speed ) {
+ speed = speed == null ? 1 : speed;
+
+ var scaled = scale( speed, this.center, 110 );
+
+ this.speed = speed;
+ this.which = "forward";
+
+ return this.move( this.center - (scaled - this.center), scaled );
+};
+
+/**
+ * reverse Move the bot in reverse
+ * rev Move the bot in reverse
+ *
+ * @param {Number}0-5, 0 is stopped, 5 is fastest
+ * @return {Object} this
+ */
+Navigator.prototype.reverse = Navigator.prototype.rev = function( speed ) {
+ speed = speed == null ? 1 : speed;
+
+ var scaled = scale( speed, this.center, 110 );
+
+ this.speed = speed;
+ this.which = "reverse";
+
+ console.log( scaled, this.center - (scaled - this.center) );
+
+ return this.move( scaled, this.center - (scaled - this.center) );
+};
+
+/**
+ * stop Stops the bot, regardless of current direction
+ * @return {Object} this
+ */
+Navigator.prototype.stop = function() {
+ this.speed = this.center;
+ this.which = "stop";
+
+ return this.move( this.center, this.center );
+};
+
+/**
+ * right Turn the bot right
+ * @return {Object} this
+ */
+
+/**
+ * left Turn the bot lefts
+ * @return {Object} this
+ */
+
+
+[ "right", "left" ].forEach(function( dir ) {
+ Navigator.prototype[ dir ] = function() {
+ var actual = this.direction[ reverseDirMap[ dir ] ];
+
+ if ( !this.isTurning ) {
+ this.isTurning = true;
+ this.move( actual, actual );
+
+ // Restore direction after turn
+ setTimeout(function() {
+
+ this[ this.which ]( this.speed );
+ this.isTurning = false;
+
+ }.bind(this), 750);
+ }
+
+ return this;
+ };
+});
+
+expandWhich = function( which ) {
+ var parts, translations;
+
+ translations = [
+ {
+ f: "forward",
+ r: "reverse",
+ fwd: "forward",
+ rev: "reverse"
+ },
+ {
+ r: "right",
+ l: "left"
+ }
+ ];
+
+ if ( which.length === 2 ) {
+ parts = [ which[0], which[1] ];
+ }
+
+ if ( !parts.length && /\-/.test(which) ) {
+ parts = which.split("-");
+ }
+
+ return parts.map(function( val, i ) {
+ return translations[ i ][ val ];
+ }).join("-");
+};
+
+Navigator.prototype.pivot = function( which, time ) {
+ var actual, directions, scaled;
+
+ scaled = scale( this.speed, this.center, 110 );
+ which = expandWhich( which );
+
+ directions = {
+ "forward-right": function() {
+ this.move( this.center, scaled );
+ },
+ "forward-left": function() {
+ this.move( this.center - (scaled - this.center), this.center );
+ },
+ "reverse-right": function() {
+ this.move( scaled, this.center );
+ },
+ "reverse-left": function() {
+ this.move( this.center, this.center - (scaled - this.center) );
+ }
+ };
+
+ directions[ which ].call( this, this.speed );
+
+ setTimeout(function() {
+
+ this[ this.which ]( this.speed );
+
+ }.bind(this), time || 1000 );
+
+ return this;
+};
+
+
+board = new five.Board();
+board.on("ready", function() {
+
+ sonar = new five.Sonar({
+ pin: "A2",
+ freq: 100
+ });
+ sonar.on("change", function() {
+ console.log( "Object is " + this.inches + "inches away" );
+ });
+
+ scanner = new five.Servo(12);
+ scanner.sweep();
+
+ this.repl.inject({
+ // create a bot, right servo = pin 10, left servo = pin 11
+ b: new Navigator({ right: 10, left: 11 })
+ });
+});
+
+```
+
+## Breadboard
+
+
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
81 docs/button-options.md
@@ -0,0 +1,81 @@
+# Button Options
+
+Run with:
+```bash
+node eg/button-options.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board, button;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ // Create a new `button` hardware instance
+ button = new five.Button({
+ board: board,
+ pin: 7,
+ holdtime: 1000
+ });
+
+ // Inject the `button` hardware into
+ // the Repl instance's context;
+ // allows direct command line access
+ board.repl.inject({
+ button: button
+ });
+
+ // Button Event API
+
+ // "down" the button is pressed
+ button.on("down", function() {
+ console.log("down");
+ });
+
+ // "hold" the button is pressed for specified time.
+ // defaults to 500ms (1/2 second)
+ // set
+ button.on("hold", function() {
+ console.log("hold");
+ });
+
+ // "up" the button is released
+ button.on("up", function() {
+ console.log("up");
+ });
+});
+
+```
+
+## Breadboard
+
+<img src="https://raw.github.com/rwldrn/johnny-five/master/docs/breadboard/button-options.png">
+
+[button-options.fzz](https://github.com/rwldrn/johnny-five/blob/master/docs/breadboard/button-options.fzz)
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
79 docs/button.md
@@ -0,0 +1,79 @@
+# Button
+
+Run with:
+```bash
+node eg/button.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board, button;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ // Create a new `button` hardware instance.
+ // This example allows the button module to
+ // create a completely default instance
+ button = new five.Button(7);
+
+ // Inject the `button` hardware into
+ // the Repl instance's context;
+ // allows direct command line access
+ board.repl.inject({
+ button: button
+ });
+
+ // Button Event API
+
+ // "down" the button is pressed
+ button.on("down", function() {
+ console.log("down");
+ });
+
+ // "hold" the button is pressed for specified time.
+ // defaults to 500ms (1/2 second)
+ // set
+ button.on("hold", function() {
+ console.log("hold");
+ });
+
+ // "up" the button is released
+ button.on("up", function() {
+ console.log("up");
+ });
+});
+
+```
+
+## Breadboard
+
+<img src="https://raw.github.com/rwldrn/johnny-five/master/docs/breadboard/button.png">
+
+[button.fzz](https://github.com/rwldrn/johnny-five/blob/master/docs/breadboard/button.fzz)
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
76 docs/claw.md
@@ -0,0 +1,76 @@
+# Claw
+
+Run with:
+```bash
+node eg/claw.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ var claw = new five.Servo({ pin: 9 }),
+ arm = five.Servo({ pin: 10 }),
+ degrees = 10,
+ incrementer = 10,
+ last;
+
+ this.loop( 25, function() {
+
+ if ( degrees >= 180 || degrees === 0 ) {
+ incrementer *= -1;
+ }
+
+ degrees += incrementer;
+
+ if ( degrees === 180 ) {
+ if ( !last || last === 90 ) {
+ last = 180;
+ } else {
+ last = 90;
+ }
+ arm.move( last );
+ }
+
+ claw.move( degrees );
+ });
+});
+
+
+// Claw Assembly Instructions
+// http://blasphemousbits.wordpress.com/2011/11/05/sparkfun-robot-claw/
+
+```
+
+## Breadboard
+
+
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
81 docs/continuous-clock.md
@@ -0,0 +1,81 @@
+# Continuous Clock
+
+Run with:
+```bash
+node eg/continuous-clock.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board, servo;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ [
+ [ 91, "ccw" ],
+ [ 89, "cw" ]
+
+ ].forEach(function( def ) {
+ five.Servo.prototype[ def[1] ] = function() {
+ this.move( def[0] );
+ };
+ });
+
+
+ // Create a new `servo` hardware instance.
+ servo = new five.Servo({
+ pin: 9,
+ // `type` defaults to standard servo.
+ // For continuous rotation servos, override the default
+ // by setting the `type` here
+ type: "continuous"
+ });
+
+ // Inject the `servo` hardware into
+ // the Repl instance's context;
+ // allows direct command line access
+ board.repl.inject({
+ servo: servo
+ });
+
+ // Continuous Rotation Servo API
+
+ // move( speed )
+ // Set the speed at which the continuous rotation
+ // servo will rotate at.
+ servo.move( 90 );
+
+});
+
+```
+
+## Breadboard
+
+
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
72 docs/continuous.md
@@ -0,0 +1,72 @@
+# Continuous
+
+Run with:
+```bash
+node eg/continuous.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board, servo;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ // Create a new `servo` hardware instance.
+ servo = new five.Servo({
+ pin: 9,
+ // `type` defaults to standard servo.
+ // For continuous rotation servos, override the default
+ // by setting the `type` here
+ type: "continuous"
+ });
+
+ // Inject the `servo` hardware into
+ // the Repl instance's context;
+ // allows direct command line access
+ board.repl.inject({
+ servo: servo
+ });
+
+ // Continuous Rotation Servo API
+
+ // move( speed )
+ // Set the speed at which the continuous rotation
+ // servo will rotate at.
+ servo.move( 90 );
+
+});
+
+```
+
+## Breadboard
+
+<img src="https://raw.github.com/rwldrn/johnny-five/master/docs/breadboard/continuous.png">
+
+[continuous.fzz](https://github.com/rwldrn/johnny-five/blob/master/docs/breadboard/continuous.fzz)
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
135 docs/hmc5883l.md
@@ -0,0 +1,135 @@
+# Hmc5883l
+
+Run with:
+```bash
+node eg/hmc5883l.js
+```
+
+
+```javascript
+var Board = require("firmata").Board,
+ address, board;
+
+address = 0x1E;
+
+board = new Board("/dev/tty.usbmodem411", function() {
+
+ var x, y, z, interval;
+
+ board.sendI2CConfig();
+ board.on("string",function( string ) {
+ console.log("string", string);
+ });
+
+ // Continuous measurement mode
+ board.sendI2CWriteRequest( address, [ 0x02, 0x00 ] );
+
+ // Set pointer to XMSB
+ board.sendI2CWriteRequest( address, [ 0x03 ] );
+
+ // initial interval wait time is 500ms
+ interval = 500;
+
+ setInterval(function() {
+
+
+ // Read 6 bytes from the register
+ board.sendI2CReadRequest( address, 6, function( data ) {
+
+ // The HMC5883L returns data in this order:
+ //
+ // XX ZZ YY
+ //
+
+ // x, y, z are initialized at top of board ready callback
+
+
+ // // XX 0, 1
+ // x = data[0] | data[1] & 0xFF;
+
+ // // ZZ 2, 3
+ // z = data[2] | data[3] & 0xFF;
+
+ // // YY 4, 5
+ // y = data[4] | data[5] & 0xFF;
+
+ // XX 0, 1
+ x = ( data[0] << 8 ) | data[1];
+
+ // ZZ 2, 3
+ z = ( data[2] << 8 ) | data[3];
+
+ // YY 4, 5
+ y = ( data[4] << 8 ) | data[5];
+
+
+ console.log( x, y, z );
+ });
+
+ }, interval );
+});
+
+/**
+
+ Example run:
+
+ 194 3 65330
+ 195 1 65330
+ 195 3 65330
+ 195 0 65330
+ 195 2 65330
+ 195 5 65331
+ 197 7 65333
+ 191 48 65347
+ 155 101 65355
+ 140 111 65351
+ 113 125 65350
+ 91 135 65351
+ 96 131 65348
+ 117 121 65347
+ 141 104 65346
+ 174 76 65346
+ 207 26 65348
+ 214 65527 65352
+ 206 65488 65347
+ 201 65478 65342
+ 201 65479 65342
+ 193 65467 65333
+ 208 7 65357
+ 176 75 65351
+ 142 101 65348
+ 134 103 65346
+ 134 102 65346
+
+
+ */
+
+```
+
+## Breadboard
+
+
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
99 docs/ir.md
@@ -0,0 +1,99 @@
+# Ir
+
+Run with:
+```bash
+node eg/ir.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ ir;
+
+five.Board().on("ready", function() {
+
+ // Create a new `Proximity` hardware instance.
+ //
+ // five.Proximity();
+ //
+ // (Alias of:
+ // new five.IR({
+ // device: "GP2Y0D805Z0F",
+ // freq: 50
+ // });
+ // )
+ //
+
+ ir = new five.IR();
+
+
+ // Properties
+
+ // ir.axis
+ //
+ // x, y, z
+ //
+
+ // ir.scaled
+ //
+ // scaled x, y, z
+ //
+ // based on value stored at (ir.scale)
+ //
+
+ // ir.heading
+ //
+ // Calculated heading degrees (calibrated for irnetic north)
+ //
+
+
+ // Magnetometer Event API
+
+ // "headingchange"
+ //
+ // Fires when the calculated heading has changed
+ //
+ ir.on("headingchange", function() {
+
+ console.log( "headingchange", Math.floor(this.heading) );
+
+ });
+
+ // "read"
+ //
+ // Fires continuously, every 66ms.
+ //
+ ir.on("read", function( err, timestamp ) {
+ console.log( "read", this.axis );
+ });
+});
+
+```
+
+## Breadboard
+
+
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
66 docs/joystick-claw.md
@@ -0,0 +1,66 @@
+# Joystick Claw
+
+Run with:
+```bash
+node eg/joystick-claw.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board, claw, joystick;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ var claw = new five.Servo({
+ pin: 9,
+ range: [ 0, 170 ]
+ }),
+ joystick = new five.Joystick({
+ pins: [ "A0", "A1" ],
+ freq: 250
+ });
+
+ // Set the claw degrees to half way
+ // (the joystick deadzone)
+ claw.move( 90 );
+
+ joystick.on("axismove", function() {
+ // Open/close the claw by setting degrees according
+ // to Y position of joystick.
+ // limit to 170 on medium servos (ei. the servo used on the claw)
+ claw.move( Math.ceil(170 * this.fixed.y) );
+ });
+});
+
+```
+
+## Breadboard
+
+
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
79 docs/joystick-laser.md
@@ -0,0 +1,79 @@
+# Joystick Laser
+
+Run with:
+```bash
+node eg/joystick-laser.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board = new five.Board({
+ debug: true
+ });
+
+board.on("ready", function() {
+ var range, pan, tilt, joystick;
+
+ range = [ 0, 170 ];
+
+ // Servo to control panning
+ pan = new five.Servo({
+ pin: 9,
+ range: range
+ });
+
+ // Servo to control tilt
+ tilt = new five.Servo({
+ pin: 10,
+ range: range
+ });
+
+ // Joystick to control pan/tilt
+ // Read Analog 0, 1
+ // Limit events to every 50ms
+ joystick = new five.Joystick({
+ pins: [ "A0", "A1" ],
+ freq: 100
+ });
+
+ // Center all servos
+ (five.Servos()).center();
+
+ joystick.on("axismove", function() {
+
+ tilt.move( Math.ceil(170 * this.fixed.y) );
+ pan.move( Math.ceil(170 * this.fixed.x) );
+
+ });
+});
+
+```
+
+## Breadboard
+
+
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
109 docs/joystick-motor-led.md
@@ -0,0 +1,109 @@
+# Joystick Motor Led
+
+Run with:
+```bash
+node eg/joystick-motor-led.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board, joystick, motor, led;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ // Create a new `joystick` hardware instance.
+ joystick = new five.Joystick({
+ // Joystick pins are an array of pins
+ // Pin orders:
+ // [ up, down, left, right ]
+ // [ ud, lr ]
+ pins: [ "A0", "A1" ],
+ freq: 25
+ });
+
+ // Attach a motor to PWM pin 5
+ motor = new five.Motor({
+ pin: 5
+ });
+
+ // Attach a led to PWM pin 9
+ led = new five.Led({
+ pin: 9
+ });
+
+ // Inject the hardware into
+ // the Repl instance's context;
+ // allows direct command line access
+ board.repl.inject({
+ joystick: joystick,
+ motor: motor,
+ led: led
+ });
+
+
+ // Pushing the joystick to up position should start the motor,
+ // releasing it will turn the motor off.
+ joystick.on("axismove", function( err, timestamp ) {
+
+ if ( !motor.isOn && this.axis.y > 0.51 ) {
+ motor.start();
+ }
+
+ if ( motor.isOn && this.axis.y < 0.51 ) {
+ motor.stop();
+ }
+ });
+
+ // While the motor is on, blink the led
+ motor.on("start", function() {
+ // 250ms
+ led.strobe( 250 );
+ });
+
+ motor.on("stop", function() {
+ led.stop();
+ });
+});
+
+
+// Schematic
+// https://1965269182786388413-a-1802744773732722657-s-sites.googlegroups.com/site/parallaxinretailstores/home/2-axis-joystick/Joystick-6.png
+// http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/27800-Axis%20JoyStick_B%20Schematic.pdf
+
+// Further Reading
+// http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/27800-2-AxisJoystick-v1.2.pdf
+
+```
+
+## Breadboard
+
+<img src="https://raw.github.com/rwldrn/johnny-five/master/docs/breadboard/joystick-motor-led.png">
+
+[joystick-motor-led.fzz](https://github.com/rwldrn/johnny-five/blob/master/docs/breadboard/joystick-motor-led.fzz)
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
97 docs/joystick.md
@@ -0,0 +1,97 @@
+# Joystick
+
+Run with:
+```bash
+node eg/joystick.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board, joystick;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ // Create a new `joystick` hardware instance.
+ joystick = new five.Joystick({
+ // Joystick pins are an array of pins
+ // Pin orders:
+ // [ up, down, left, right ]
+ // [ ud, lr ]
+ pins: [ "A0", "A1" ],
+ freq: 500
+ });
+
+ // Inject the `joystick` hardware into
+ // the Repl instance's context;
+ // allows direct command line access
+ board.repl.inject({
+ joystick: joystick
+ });
+
+ // Joystick Event API
+
+ joystick.on("axismove", function( err, timestamp ) {
+
+ // Axis data is available on:
+ // this.axis
+ // {
+ // x: 0...1, ( 0 <-- L/R --> 1 )
+ // y: 0...1 ( 0 <-- D/U --> 1 )
+ // }
+ //
+ // Center is ~0.5
+ //
+ // console.log( "input", this.axis );
+ // console.log( "LR:", this.axis.x, this.normalized.x );
+ // console.log( "UD:", this.axis.y, this.normalized.y );
+ // console.log( "MAG:", this.magnitude );
+
+ console.log( "LR:", this.fixed.x );
+ console.log( "UD:", this.fixed.y );
+ console.log( "MAG:", this.magnitude );
+
+ });
+});
+
+
+// Schematic
+// https://1965269182786388413-a-1802744773732722657-s-sites.googlegroups.com/site/parallaxinretailstores/home/2-axis-joystick/Joystick-6.png
+// http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/27800-Axis%20JoyStick_B%20Schematic.pdf
+
+// Further Reading
+// http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/27800-2-AxisJoystick-v1.2.pdf
+
+```
+
+## Breadboard
+
+<img src="https://raw.github.com/rwldrn/johnny-five/master/docs/breadboard/joystick.png">
+
+[joystick.fzz](https://github.com/rwldrn/johnny-five/blob/master/docs/breadboard/joystick.fzz)
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
52 docs/laser.md
@@ -0,0 +1,52 @@
+# Laser
+
+Run with:
+```bash
+node eg/laser.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board, laser;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ laser = new five.Led(9);
+
+ board.repl.inject({
+ laser: laser
+ });
+});
+
+```
+
+## Breadboard
+
+
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
59 docs/lcd.md
@@ -0,0 +1,59 @@
+# Lcd
+
+Run with:
+```bash
+node eg/lcd.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ lcd;
+
+five.Board().on("ready", function() {
+
+
+ lcd = new five.LCD({
+ cols: 10,
+ rows: 2,
+ dots: "5x8"
+ });
+
+
+ this.repl.inject({
+ lcd: lcd
+ });
+
+
+
+});
+
+```
+
+## Breadboard
+
+
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
80 docs/led-fade.md
@@ -0,0 +1,80 @@
+# Led Fade
+
+Run with:
+```bash
+node eg/led-fade.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board, led;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ // Create a standard `led` hardware instance
+ led = new five.Led({
+ // Use PWM pin 9 for fading example
+ pin: 9
+ });
+
+ // pinMode is set to OUTPUT by default
+
+ // Inject the `led` hardware into
+ // the Repl instance's context;
+ // allows direct command line access
+ board.repl.inject({
+ led: led
+ });
+
+ // "fade" to the value, 0-255, in the given time.
+ // Defaults to 1000ms
+ // pinMode will be changed to PWM automatically
+ //
+ // led.fade( 255, 3000 );
+
+
+ led.fadeIn();
+
+
+ // Toggle the led after 10 seconds (shown in ms)
+ this.wait( 5000, function() {
+
+ led.fadeOut();
+
+ });
+});
+
+```
+
+## Breadboard
+
+<img src="https://raw.github.com/rwldrn/johnny-five/master/docs/breadboard/led-fade.png">
+
+[led-fade.fzz](https://github.com/rwldrn/johnny-five/blob/master/docs/breadboard/led-fade.fzz)
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
66 docs/led-on-off.md
@@ -0,0 +1,66 @@
+# Led On Off
+
+Run with:
+```bash
+node eg/led-on-off.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board, led;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ // Create a standard `led` hardware instance
+ led = new five.Led({
+ pin: 13
+ });
+
+ // "on" turns the led _on_
+ led.on();
+
+ // "off" turns the led _off_
+ led.off();
+
+ // Turn the led back on after 3 seconds (shown in ms)
+ this.wait( 3000, function() {
+
+ led.on();
+
+ });
+});
+
+```
+
+## Breadboard
+
+<img src="https://raw.github.com/rwldrn/johnny-five/master/docs/breadboard/led-on-off.png">
+
+[led-on-off.fzz](https://github.com/rwldrn/johnny-five/blob/master/docs/breadboard/led-on-off.fzz)
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
76 docs/led-pulse.md
@@ -0,0 +1,76 @@
+# Led Pulse
+
+Run with:
+```bash
+node eg/led-pulse.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board, led;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ // Create a standard `led` hardware instance
+ led = new five.Led({
+ // Use PWM pin 9 for fading example
+ pin: 9
+ });
+
+ // pinMode is set to OUTPUT by default
+
+ // Inject the `led` hardware into
+ // the Repl instance's context;
+ // allows direct command line access
+ board.repl.inject({
+ led: led
+ });
+
+ // "pulse" the led in a looping interval
+ // Interval defaults to 1000ms
+ // pinMode is will be changed to PWM automatically
+ led.pulse();
+
+
+ // Turn off the led pulse loop after 10 seconds (shown in ms)
+ this.wait( 10000, function() {
+
+ led.off();
+
+ });
+});
+
+```
+
+## Breadboard
+
+<img src="https://raw.github.com/rwldrn/johnny-five/master/docs/breadboard/led-pulse.png">
+
+[led-pulse.fzz](https://github.com/rwldrn/johnny-five/blob/master/docs/breadboard/led-pulse.fzz)
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
56 docs/led-rgb.md
@@ -0,0 +1,56 @@
+# Led Rgb
+
+Run with:
+```bash
+node eg/led-rgb.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board, red, green, blue, leds;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ red = new five.Led(9);
+ green = new five.Led(10);
+ blue = new five.Led(11);
+
+ leds = new five.Leds();
+
+
+ // leds.pulse( 5000 );
+ leds.pulse( 5000 );
+});
+
+```
+
+## Breadboard
+
+
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
54 docs/led-strobe.md
@@ -0,0 +1,54 @@
+# Led Strobe
+
+Run with:
+```bash
+node eg/led-strobe.js
+```
+
+
+```javascript
+var five = require("johnny-five"),
+ board, led;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ // Create a standard `led` hardware instance
+ led = new five.Led(13);
+
+ // "strobe" the led in 100ms on-off phases
+ led.strobe( 100 );
+});
+
+```
+
+## Breadboard
+
+<img src="https://raw.github.com/rwldrn/johnny-five/master/docs/breadboard/led-strobe.png">
+
+[led-strobe.fzz](https://github.com/rwldrn/johnny-five/blob/master/docs/breadboard/led-strobe.fzz)
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
146 docs/magnetometer-log.md
@@ -0,0 +1,146 @@
+# Magnetometer Log
+
+Run with:
+```bash
+node eg/magnetometer-log.js
+```
+
+
+```javascript
+var color = require("colors"),
+ five = require("johnny-five"),
+ board, colors, servo, mag, count, dirs, lock;
+
+(board = new five.Board()).on("ready", function() {
+
+ count = -1;
+ dirs = [ "cw", "ccw" ];
+ lock = false;
+
+ [
+ [ 92, "ccw" ],
+ [ 88, "cw" ]
+
+ ].forEach(function( def ) {
+ five.Servo.prototype[ def[1] ] = function() {
+ this.move( def[0] );
+ };
+ });
+
+
+ // Create a new `servo` hardware instance.
+ servo = new five.Servo({
+ pin: 9,
+ // `type` defaults to standard servo.
+ // For continuous rotation servos, override the default
+ // by setting the `type` here
+ type: "continuous"
+ });
+
+
+ // Create an I2C `Magnetometer` instance
+ mag = new five.Magnetometer();
+
+ this.repl.inject({
+ servo: servo,
+ mag: mag
+ });
+
+ // set the continuous servo to stopped
+ servo.move( 90 );
+
+ // As the heading changes, log heading value
+ mag.on("headingchange", function() {
+ var log;
+
+ log = ( this.bearing.name + " " + Math.floor(this.heading) + "°" );
+
+ console.log(
+ log[ colors[ this.bearing.abbr ] ]
+ );
+
+
+
+ if ( !lock && this.bearing.name === "North" ) {
+ // Set redirection lock
+ lock = true;
+
+ // Redirect
+ servo[ dirs[ ++count % 2 ] ]();
+
+ // Release redirection lock
+ board.wait( 2000, function() {
+ lock = false;
+ });
+ }
+ });
+
+ this.wait( 2000, function() {
+ servo[ dirs[ ++count % 2 ] ]();
+ });
+});
+
+colors = {
+ N: "red",
+ NbE: "red",
+ NNE: "red",
+ NEbN: "red",
+ NE: "yellow",
+ NEbE: "yellow",
+ ENE: "yellow",
+ EbN: "yellow",
+ E: "green",
+ EbS: "green",
+ ESE: "green",
+ SEbE: "green",
+ SE: "green",
+ SEbS: "cyan",
+ SSE: "cyan",
+ SbE: "cyan",
+ S: "cyan",
+ SbW: "cyan",
+ SSW: "cyan",
+ SWbS: "blue",
+ SW: "blue",
+ SWbW: "blue",
+ WSW: "blue",
+ WbS: "blue",
+ W: "magenta",
+ WbN: "magenta",
+ WNW: "magenta",
+ NWbW: "magenta",
+ NW: "magenta",
+ NWbN: "magenta",
+ NNW: "magenta",
+ NbW: "red"
+};
+
+```
+
+## Breadboard
+
+
+
+
+## Documentation
+
+_(Nothing yet)_
+
+
+
+
+
+
+
+
+
+## Contributing
+All contributions must adhere to the 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.
View
150 docs/magnetometer-north.md
@@ -0,0 +1,150 @@
+# Magnetometer North
+
+Run with:
+```bash
+node eg/magnetometer-north.js
+```
+
+
+```javascript
+var color = require("colors"),
+ five = require("johnny-five"),
+ board, colors, servo, mag, count, dirs, isNorth, isSeeking, last;
+
+board = new five.Board();
+
+board.on("ready", function() {
+
+ count = -1;
+ dirs = [ "cw", "ccw" ];
+ isNorth = false;
+ isSeeking = false;
+
+ [
+ [ 95, "ccw" ],
+ [ 85, "cw" ]
+
+ ].forEach(function( def ) {
+ five.Servo.prototype[ def[1] ] = function() {
+ this.move( def[0] );
+ };
+ });
+
+
+ // Create a new `servo` hardware instance.
+ servo = new five.Servo({
+ pin: 9,
+ // `type` defaults to standard servo.
+ // For continuous rotation servos, override the default
+ // by setting the `type` here
+ type: "continuous"
+ });
+
+
+ // Create an I2C `Magnetometer` instance
+ mag = new five.Magnetometer();
+
+ this.repl.inject({
+ servo: servo,
+ mag: mag
+ });
+
+ // set the continuous servo to stopped
+ servo.move( 90 );
+
+ // As the heading changes, log heading value
+ mag.on("read", function() {
+ var heading = Math.floor( this.heading );
+
+ if ( heading > 345 || heading < 15 ) {
+
+ if ( !isNorth ) {
+ console.log( "FOUND north!".yellow );
+ isSeeking = false;
+ }