Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rebuild all example program markdown files
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
- Loading branch information
Showing
56 changed files
with
5,957 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
Oops, something went wrong.