Skip to content

Instantly share code, notes, and snippets.

@szolotykh
Created December 22, 2014 16:27
Show Gist options
  • Save szolotykh/77db08bd2ac0a733d6a9 to your computer and use it in GitHub Desktop.
Save szolotykh/77db08bd2ac0a733d6a9 to your computer and use it in GitHub Desktop.
Send tone command to Lego NXT
var SerialPort = require("serialport").SerialPort
var serialPort = new SerialPort("COM4", {
baudrate: 9600
});
serialPort.on("open", function () {
console.log('open');
serialPort.on('data', function(data) {
console.log('Data received: ' + data);
});
var command = new Buffer([0x06, 0x00, 0x80, 0x03, 0x0B, 0x02, 0xF4, 0x01]);
serialPort.write(command, function(err, results) {
console.log('Error ' + err);
console.log('results ' + results);
serialPort.close();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment