-
-
Save iamblue/27d79a58827093f4442c to your computer and use it in GitHub Desktop.
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
var mcs = require('mcsjs'); | |
// regist your device to mcs. | |
var myApp = mcs.register({ | |
deviceId: 'Input your deviceId', // Input your deviceId. | |
deviceKey: 'Input your deviceKey', // Input your deviceKey. | |
}); | |
var SerialPort = require("serialport").SerialPort; | |
var serialPort = new SerialPort("/dev/ttyS0", { | |
baudrate: 57600 | |
}); | |
// communicate with Arduino chip (32U4). | |
serialPort.on("open", function () { | |
// listen the mcs command. | |
myApp.on('gamepad', function(data, time) { // gamepad is your datachannel. | |
serialPort.write(data); // send message to Arduino chip. | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment