Created
February 8, 2017 10:32
-
-
Save willmendesneto/915686b35488d3ca45b404d99f4c130d to your computer and use it in GitHub Desktop.
First version of memory game
This file contains hidden or 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
var five = require("johnny-five"), | |
board, button; | |
board = new five.Board(); | |
board.on("ready", function() { | |
// Create a new `button` hardware instance. | |
// This example allows the button module to | |
// create a completely default instance | |
button = new five.Button(2); | |
// Inject the `button` hardware into | |
// the Repl instance's context; | |
// allows direct command line access | |
// board.repl.inject({ | |
// button: button | |
// }); | |
// Button Event API | |
// "down" the button is pressed | |
button.on("down", function() { | |
console.log("down"); | |
}); | |
// "hold" the button is pressed for specified time. | |
// defaults to 500ms (1/2 second) | |
// set | |
button.on("hold", function() { | |
console.log("hold"); | |
}); | |
// "up" the button is released | |
button.on("up", function() { | |
console.log("up"); | |
}); | |
}); |
This file contains hidden or 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
var five = require("johnny-five"), | |
board, button1, button2; | |
board = new five.Board(); | |
board.on("ready", function() { | |
// Create a new `button` hardware instance. | |
// This example allows the button module to | |
// create a completely default instance | |
button1 = new five.Button(2); | |
button2 = new five.Button(4); | |
// Inject the `button` hardware into | |
// the Repl instance's context; | |
// allows direct command line access | |
// board.repl.inject({ | |
// button: button | |
// }); | |
// Button Event API | |
// "down" the button is pressed | |
button1.on("down", function() { | |
console.log("down 1"); | |
}); | |
// "hold" the button is pressed for specified time. | |
// defaults to 500ms (1/2 second) | |
// set | |
button1.on("hold", function() { | |
console.log("hold 1"); | |
}); | |
// "up" the button is released | |
button1.on("up", function() { | |
console.log("up 1"); | |
}); | |
// "down" the button is pressed | |
button2.on("down", function() { | |
console.log("down 2"); | |
}); | |
// "hold" the button is pressed for specified time. | |
// defaults to 500ms (1/2 second) | |
// set | |
button2.on("hold", function() { | |
console.log("hold 2"); | |
}); | |
// "up" the button is released | |
button2.on("up", function() { | |
console.log("up 2"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment