Denis Cousineau home page


The PDF documents on this site were made with PrimoPDF.
Get a reader free.

The Notebook documents on this site were made with Mathematica.
Get the reader free.

Pages © Denis Cousineau;
last modified: November 29th, 2011;
page consulted on


Programming the Lego NXT using Mathematica with Math4NXT

The Lego NXT is the latest programmable brick. It can be used to build Lego robots. It comes with many sensors and other sensors can be build from alternate sources. It can control up to three motors (either tachomotors or regular motors). Finally, it can communicate with a PC using a USB cable or a BlueTooth link.

The NXT brick with sensors and motors

Download area: Math4NXT package and related files

  • Math4NXT.m : The Mathematica package to control the NXT.
  • : The SerialIO package; better go to the Wolfram library archive (see Raguet-Schofield reference below).
  • MotorControl22.rxe : The PID controller for the motors from Atorf et al. (see reference below).

More documentation

Example files

Some references

Atorf, L. et al. (2009) The motor control MotorControl22.rxe [binary file]

Behrens, A.,Atorf, L., Schwann, R., Neumann, B. ,Schnitzler, R. ,Ballé, J., Herold, T., Telle, A., Noll, T.G., Hameyer K., & Aach, T. (2010) MATLAB Meets LEGO Mindstorms - A Freshman Introduction Course Into Practical Engineering, IEEE Transactions on Education, vol. 53(2), pp.306-317.

Behrens et al. (2009) Mindstorms NXT toolbox for Matlab.

HiTechnic (2011) Alternate sensors for the NXT brick.

The Lego Group Mindstorms web site,

The Lego group, (2006) Lego Mindstorms NXT BlueTooth developper kit. Available at

McLoone, J. (2010) How to make a webcam intruder alarm with mathematica. Wolfram blog.

Raguet-Schofield, R. (2005,2009) SerialIO (Mathematica package). Available from Wolfram Library Archive,