Skip to content

Commit

Permalink
Examples: LUDUS
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Aug 26, 2015
1 parent 75c1516 commit 0445a00
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ To interactively navigate the examples, visit the [Johnny-Five examples](http://
- [Motor - Current](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-current.md)
- [Motor - H-Bridge](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-hbridge.md)
- [Motor - PCA9685](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-PCA9685.md)
- [Motor - LUDUS](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-LUDUS.md)
- [Motor - 3 pin](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-3-pin.md)

### Stepper Motor
Expand Down
80 changes: 80 additions & 0 deletions docs/motor-LUDUS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!--remove-start-->

# Motor - LUDUS

<!--remove-end-->








Run with:
```bash
node eg/motor-LUDUS.js
```


```javascript
var five = require("johnny-five");
var keypress = require("keypress");
var board = new five.Board();

board.on("ready", function() {
var motors = new five.Motors([
five.Motor.SHIELD_CONFIGS.SPARKFUN_LUDUS.A, // Left
five.Motor.SHIELD_CONFIGS.SPARKFUN_LUDUS.B, // Right
]);
var speed = 100;

function controller(ch, key) {
if (key) {
if (key.name === "space") {
motors.stop();
}
if (key.name === "up") {
motors.fwd(speed);
}
if (key.name === "down") {
motors.rev(speed);
}
if (key.name === "right") {
motors[0].fwd(speed * 0.75);
motors[1].rev(speed * 0.75);
}
if (key.name === "left") {
motors[0].rev(speed * 0.75);
motors[1].fwd(speed * 0.75);
}
}
}

keypress(process.stdin);

process.stdin.on("keypress", controller);
process.stdin.setRawMode(true);
process.stdin.resume();
});

```








&nbsp;

<!--remove-start-->

## License
Copyright (c) 2012, 2013, 2014 Rick Waldron <waldron.rick@gmail.com>
Licensed under the MIT license.
Copyright (c) 2014, 2015 The Johnny-Five Contributors
Licensed under the MIT license.

<!--remove-end-->

0 comments on commit 0445a00

Please sign in to comment.