-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #785 from rwaldron/joystick
Joystick: Controller refactor, Esplora support.
- Loading branch information
Showing
15 changed files
with
1,087 additions
and
217 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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,70 @@ | ||
<!--remove-start--> | ||
|
||
# Joystick - Esplora | ||
|
||
|
||
|
||
Run with: | ||
```bash | ||
node eg/joystick-esplora.js | ||
``` | ||
|
||
<!--remove-end--> | ||
|
||
```javascript | ||
var five = require("johnny-five"); | ||
var board = new five.Board(); | ||
|
||
board.on("ready", function() { | ||
/* | ||
Be sure to reflash your Esplora with StandardFirmata! | ||
In the Arduino IDE: | ||
Tools > Boards > Arduino Leonard or Arduino Esplora | ||
*/ | ||
var joystick = new five.Joystick({ | ||
controller: "ESPLORA" | ||
}); | ||
|
||
joystick.on("change", function() { | ||
console.log("Joystick"); | ||
console.log(" x : ", this.x); | ||
console.log(" y : ", this.y); | ||
console.log("--------------------------------------"); | ||
}); | ||
}); | ||
|
||
``` | ||
|
||
|
||
## Illustrations / Photos | ||
|
||
|
||
### Joystick - Esplora | ||
|
||
|
||
Esplora joystick example. | ||
|
||
|
||
![docs/breadboard/esplora.png](breadboard/esplora.png)<br> | ||
|
||
Fritzing diagram: [docs/breadboard/esplora.fzz](breadboard/esplora.fzz) | ||
|
||
| ||
|
||
|
||
|
||
|
||
|
||
| ||
|
||
<!--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--> |
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,62 @@ | ||
<!--remove-start--> | ||
|
||
# Joystick - Sparkfun Shield | ||
|
||
|
||
|
||
Run with: | ||
```bash | ||
node eg/joystick-shield.js | ||
``` | ||
|
||
<!--remove-end--> | ||
|
||
```javascript | ||
var five = require("johnny-five"); | ||
var board = new five.Board(); | ||
|
||
board.on("ready", function() { | ||
var joystick = new five.Joystick({ | ||
pins: ["A0", "A1"], | ||
invertY: true | ||
}); | ||
|
||
joystick.on("change", function() { | ||
console.log("Joystick"); | ||
console.log(" x : ", this.x); | ||
console.log(" y : ", this.y); | ||
console.log("--------------------------------------"); | ||
}); | ||
}); | ||
|
||
``` | ||
|
||
|
||
## Illustrations / Photos | ||
|
||
|
||
### Joystick - Sparkfun Shield | ||
|
||
|
||
Sparkfun Joystick Shield example. | ||
|
||
|
||
![docs/breadboard/joystick-shield.png](breadboard/joystick-shield.png)<br> | ||
|
||
| ||
|
||
|
||
|
||
|
||
|
||
| ||
|
||
<!--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--> |
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,22 @@ | ||
var five = require("../lib/johnny-five.js"); | ||
var board = new five.Board(); | ||
|
||
board.on("ready", function() { | ||
/* | ||
Be sure to reflash your Esplora with StandardFirmata! | ||
In the Arduino IDE: | ||
Tools > Boards > Arduino Leonard or Arduino Esplora | ||
*/ | ||
var joystick = new five.Joystick({ | ||
controller: "ESPLORA" | ||
}); | ||
|
||
joystick.on("change", function() { | ||
console.log("Joystick"); | ||
console.log(" x : ", this.x); | ||
console.log(" y : ", this.y); | ||
console.log("--------------------------------------"); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,40 +1,34 @@ | ||
var five = require("../lib/johnny-five.js"), | ||
board = new five.Board({ | ||
debug: true | ||
}); | ||
var five = require("../lib/johnny-five.js"); | ||
var board = new five.Board(); | ||
|
||
board.on("ready", function() { | ||
var range, pan, tilt, joystick; | ||
|
||
range = [0, 170]; | ||
var range = [0, 170]; | ||
|
||
// Servo to control panning | ||
pan = new five.Servo({ | ||
var pan = new five.Servo({ | ||
pin: 9, | ||
range: range | ||
range: range, | ||
center: true | ||
}); | ||
|
||
// Servo to control tilt | ||
tilt = new five.Servo({ | ||
var tilt = new five.Servo({ | ||
pin: 10, | ||
range: range | ||
range: range, | ||
center: true | ||
}); | ||
|
||
// Joystick to control pan/tilt | ||
// Read Analog 0, 1 | ||
// Limit events to every 50ms | ||
joystick = new five.Joystick({ | ||
var joystick = new five.Joystick({ | ||
pins: ["A0", "A1"], | ||
freq: 100 | ||
}); | ||
|
||
// Center all servos | ||
(five.Servos()).center(); | ||
|
||
joystick.on("axismove", function() { | ||
|
||
tilt.to(Math.ceil(170 * this.fixed.y)); | ||
pan.to(Math.ceil(170 * this.fixed.x)); | ||
|
||
joystick.on("change", function() { | ||
tilt.to(five.Fn.scale(this.y, -1, 1, 0, 170)); | ||
pan.to(five.Fn.scale(this.x, -1, 1, 0, 170)); | ||
}); | ||
}); |
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,16 @@ | ||
var five = require("../lib/johnny-five.js"); | ||
var board = new five.Board(); | ||
|
||
board.on("ready", function() { | ||
var joystick = new five.Joystick({ | ||
pins: ["A0", "A1"], | ||
invertY: true | ||
}); | ||
|
||
joystick.on("change", function() { | ||
console.log("Joystick"); | ||
console.log(" x : ", this.x); | ||
console.log(" y : ", this.y); | ||
console.log("--------------------------------------"); | ||
}); | ||
}); |
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
Oops, something went wrong.