Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Johnny-five 🤖 and changed mapping on controller 🎮 #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ If you're using Windows or Mac, ensure that you have the USB driver:
### Install Dependencies

* Install git
* Install Node 4.4 (or greater)
* Install Node 8.16.0 (or greater)

```
git clone https://github.com/EmergingTechnologyAdvisors/mbot-soccer
Expand Down
24 changes: 12 additions & 12 deletions eg/gamepad.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ setInterval(gamepad.detectDevices, 500);

// Listen for move events on all gamepads
gamepad.on('move', function (id, axis, value) {
if (axis == 4 && value == -1) {
if (axis == 0 && value == -1) {
console.log('moving left');
motors.left.fwd(MAX_SPEED);
motors.right.fwd(MAX_SPEED);
}
if (axis == 4 && value == 0) {
console.log('turning stopping');
motors.left.stop();
motors.right.stop();
}
if (axis == 4 && value == 1) { //moving right
// if (axis == 2 ) {
// console.log('turning stopping');
// motors.left.stop();
// motors.right.stop();
// }
if (axis == 0 && value == 1) { //moving right
console.log('moving right');
motors.left.rev(MAX_SPEED);
motors.right.rev(MAX_SPEED);
Expand All @@ -64,27 +64,27 @@ gamepad.on('up', function (id, num) { //when turbo or forward is up stop
});

gamepad.on('down', function (id, num) {
if (num == 1) { // A button
if (num == 2) { // A button
console.log('Forward');
motors.left.rev(MAX_SPEED);
motors.right.fwd(MAX_SPEED);
}
if (num == 0) { // X button
if (num == 3) { // X button
console.log('Turbo!!!');
motors.left.rev(255);
motors.right.fwd(255);
}
if (num == 2) { // B button
if (num == 1) { // B button
console.log('Going backward');
motors.left.fwd(MAX_SPEED);
motors.right.rev(MAX_SPEED);
}
if (num == 3) { // Y button
if (num == 0) { // Y button
console.log('Rick Rolled!!');
motors.left.fwd(MAX_SPEED);
motors.right.fwd(MAX_SPEED);
}
if (num == 4) { //left trigger L1
if (num == 6) { //left trigger L1
console.log('Quitting');
motors.left.stop();
motors.right.stop();
Expand Down
Loading