Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 73 lines (41 sloc) 1.232 kb
6b5ab5b @rwaldron Rebuild all example program markdown files
authored
1 # Joystick Claw
2
3 Run with:
4 ```bash
5 node eg/joystick-claw.js
6 ```
7
8
9 ```javascript
10 var five = require("johnny-five"),
11 board, claw, joystick;
12
13 board = new five.Board();
14
15 board.on("ready", function() {
16
17 var claw = new five.Servo({
18 pin: 9,
19 range: [ 0, 170 ]
20 }),
21 joystick = new five.Joystick({
22 pins: [ "A0", "A1" ],
23 freq: 250
24 });
25
26 // Set the claw degrees to half way
27 // (the joystick deadzone)
28 claw.move( 90 );
29
30 joystick.on("axismove", function() {
31 // Open/close the claw by setting degrees according
32 // to Y position of joystick.
33 // limit to 170 on medium servos (ei. the servo used on the claw)
34 claw.move( Math.ceil(170 * this.fixed.y) );
35 });
36 });
37
38 ```
39
40 ## Breadboard
41
42
43
44
5e929ce @rwaldron Example program updates
authored
45
46 ## Devices
47
48
49
50
6b5ab5b @rwaldron Rebuild all example program markdown files
authored
51 ## Documentation
52
53 _(Nothing yet)_
54
55
56
57
58
59
60
61
62
63 ## Contributing
9558a90 @rwaldron Update docs files
authored
64 All contributions must adhere to the [Idiomatic.js Style Guide](https://github.com/rwldrn/idiomatic.js),
6b5ab5b @rwaldron Rebuild all example program markdown files
authored
65 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).
66
67 ## Release History
68 _(Nothing yet)_
69
70 ## License
71 Copyright (c) 2012 Rick Waldron <waldron.rick@gmail.com>
72 Licensed under the MIT license.
Something went wrong with that request. Please try again.