Skip to content
Node.js package to control the LEGO MINDSTORMS NXT
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


nodejs-nxt is a Node.js package to control the LEGO MINDSTORMS NXT with an USB cable or a Bluethooth connection.

How I did it

I used the official communication protocol, which communicates with the nxt over its serial port. You can find the documentation here.

How to install

Nodejs-nxt could be installed with a simple

$ npm install nodejs-nxt

Usage example

The following example code connects with the NXT through the serial port '/dev/tty.NXT-DevB', plays a tone with 1000 Hz for 2 seconds and then disconnects.

var nxt = require('nodejs-nxt');
var nxt0 = new nxt.NXT('/dev/tty.NXT-DevB', true);

nxt0.Connect(function(error) {
  if (error) {
    console.log('Could not connect to the device!');
  } else {
    nxt0.PlayTone(1000, 2000, function(error) {
      if (error) {
        console.log('Could not play the tone!');



Nodejs-nxt needs the package node-serialport to communicate with the NXT.

Known bugs

  • The ultrasonic-sensor doesn't work yet

To do

  • Fix bugs (see above)
  • API documentation
  • Add system commands
  • Add another layer of functions for ease of use



You can’t perform that action at this time.