Skip to content

Commit

Permalink
Fix error in VNH5019 example
Browse files Browse the repository at this point in the history
I also noticed that this doc file was not being generated, so I added it.
  • Loading branch information
dtex authored and rwaldron committed Aug 23, 2019
1 parent 08ba5b7 commit ff4da5f
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ To get you up and running quickly, we provide a variety of examples for using ea

To interactively navigate the examples, visit the [Johnny-Five examples](http://johnny-five.io/examples/) page on the official website. If you want to link directly to the examples in this repo, you can use one of the following links.

**There are presently 361 example programs with code and diagrams!**
**There are presently 362 example programs with code and diagrams!**

<!--extract-start:examples-->

Expand Down Expand Up @@ -263,6 +263,7 @@ To interactively navigate the examples, visit the [Johnny-Five examples](http://
- [Motor - H-Bridge](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-hbridge.md)
- [Motor - LUDUS](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-LUDUS.md)
- [Motor - PCA9685](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-PCA9685.md)
- [Motor - Pololu VNH5019 Dual Motor Driver Breakout](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-vnh5019.md)
- [Motor - Sparkfun Dual H-bridge Edison Block](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-sparkfun-edison-hbridge.md)
- [Motor - Sparkfun TB6612FNG](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-TB6612FNG.md)
- [Motor - l298 Breakout](https://github.com/rwaldron/johnny-five/blob/master/docs/motor-l298-breakout.md)
Expand Down
96 changes: 96 additions & 0 deletions docs/motor-vnh5019.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<!--remove-start-->

# Motor - Pololu VNH5019 Dual Motor Driver Breakout

<!--remove-end-->








Run this example from the command line with:
```bash
node eg/motor-vnh5019.js
```


```javascript
const {Board, Motor} = require("johnny-five");
const board = new Board();

board.on("ready", () => {

// You can configure with explicit pins settings
const m1 = new Motor({
pins: {
pwm: 9,
dir: 2,
cdir: 4,
enable: 6
}
});

// Or you can configure using the built in configs
const m2 = new Motor(Motor.SHIELD_CONFIGS.POLOLU_VNH5019_SHIELD.M2);

// Inject the `motor` hardware into
// the Repl instance's context;
// allows direct command line access
board.repl.inject({
m1,
m2
});

// "start" events fire when the motor is started.
[m1, m2].forEach((motor, index) => {
motor.on("start", () => {
console.log(`start motor ${index+1}`);

// Demonstrate motor stop in 2 seconds
board.wait(2000, motor.stop);
});
});

[m1, m2].forEach( motor => {

// "stop" events fire when the motor is stopped.
motor.on("stop", () => console.log("stop"));
});

// Motor API

// start([speed)
// Start the motor. `isOn` property set to |true|
// Takes an optional parameter `speed` [0-255]
// to define the motor speed if a PWM Pin is
// used to connect the motor.
m1.start();
m2.start();

// stop()
// Stop the motor. `isOn` property set to |false|
});

```








&nbsp;

<!--remove-start-->

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

<!--remove-end-->
2 changes: 1 addition & 1 deletion eg/motor-vnh5019.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ board.on("ready", () => {
console.log(`start motor ${index+1}`);

// Demonstrate motor stop in 2 seconds
this.wait(2000, motor.stop);
board.wait(2000, motor.stop);
});
});

Expand Down
4 changes: 4 additions & 0 deletions tpl/programs.json
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,10 @@
{
"file": "motor-drv8871.js",
"title": "Motor - Adafruit DRV8871 DC Motor Driver Breakout"
},
{
"file": "motor-vnh5019.js",
"title": "Motor - Pololu VNH5019 Dual Motor Driver Breakout"
}
]
},
Expand Down

0 comments on commit ff4da5f

Please sign in to comment.