Skip to content

Instantly share code, notes, and snippets.

@iamblue
Created December 29, 2015 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamblue/27d79a58827093f4442c to your computer and use it in GitHub Desktop.
Save iamblue/27d79a58827093f4442c to your computer and use it in GitHub Desktop.
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