johnny-five
Version:
The JavaScript Robotics and Hardware Programming Framework. Use with: Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, pcDuino3, Raspberry Pi, Particle/Spark Core & Photon, Tessel 2, TI Launchpad and more!
35 lines (29 loc) • 739 B
JavaScript
var five = require("../");
var board = new five.Board();
board.on("ready", function() {
var vkey = new five.Keypad("A0");
// TODO: digital 10 pin keypad
// var dkey = new five.Keypad({
// // Digital Pins must be mapped to
// // appropriate keypad number.
// // pin => num/char
// pins: {
// // ?
// }
// });
var ikey = new five.Keypad({
controller: "MPR121",
address: 0x5A
});
var pads = {
vkey: vkey,
ikey: ikey,
};
Object.keys(pads).forEach(function(key) {
["change", "press", "hold", "release"].forEach(function(event) {
pads[key].on(event, function(data) {
console.log("Pad: %s, Event: %s, Which: %s", key, event, data);
});
});
});
});