Skip to content

Node.js package to control the LEGO MINDSTORMS NXT

License

Notifications You must be signed in to change notification settings

boneskull/nodejs-nxt

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

nodejs-nxt

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!');
      }

      nxt0.Disconnect();
    });
  }
});

Dependancy

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

License

GPLv3

About

Node.js package to control the LEGO MINDSTORMS NXT

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%