Monday, June 10, 2013

Lego Mindstorms NXT Part 2: Programming

Lego Mindstorms NXT programming is very simple programs. It can be created using the menu on the NXT Intelligent Brick. More complicated programs and sound files can be downloaded using a USB port or wirelessly using Bluetooth. Files can also be copied between two NXT bricks wirelessly, and some mobile phones can be used as a remote control. Up to three NXT bricks can communicate simultaneously via Bluetooth when user created programs are run.

The retail version of the kit includes software for writing programs that run on Microsoft and Macintosh personal computers. The software is based on National Instruments LabVIEW and provides a visual programming language for writing simple programs and downloading them to the NXT Brick. This means that rather than requiring users to write lines of code, they instead can use flowchart like "blocks" to design their program.


NXT-G v2.0 is a graphical programming environment that comes bundled with the NXT. With careful construction of blocks and wires to encapsulate complexity, NXT-G can be used for real-world programming. Parallel "sequence beams" are actually parallel threads, so this software is quite good for running a handful of parallel sense/respond loops (example: wait 60 seconds, play a "bonk" sound at low volume if battery is low, loop), or blending autonomous control with bluetooth or other "remote control". The language supports virtual instruments for all LEGO branded and most 3rd party sensors/components. Version 2.0 contains new tutorial challenges, a remote control, custom graphics and sound designers, and new LEGO color sensor support. 

C# with Microsoft Robotics Developer Studio

Free tools (Visual Studio Express in combination with the Robotics Developer Studio) enable programming the NXT using the C# language. Other supported languages include IronPython and VB.NET.

BricxCC, Next Byte Codes, Not eXactly C

Bricx Command Center (BricxCC) is the integrated development environment (IDE) used to write, compile, and edit NBC and NXC programs for the NXT. Also, as BricxCC was originally made for the RCX, programs for it can be written using NQC via BricxCC. Different firmwares can be flashed to the NXT using BricxCC.

BricxCC has many utilities such as NeXTExplorer (upload/download files, defragment the NXT, use file hex viewer), NeXTScreen (view what's on the NXT's LCD display, and capture images and video).

Next Byte Codes (NBC) is a simple open source language with an assembly language syntax that can be used to program the NXT brick. BricxCC also has the capability to decompile standard .rxe NXT executables to NBC

Not eXactly C (NXC) is a high level open-source language, similar to C, built on the NBC compiler. It can also be used to program the NXT brick. NXC is basically NQC for the NXT. It is one of the most widely used third-party programming languages for the NXT. In NXC, even creating video games for the NXT is possible. Some people have even got working grayscale on the NXT Screen.


Robolab 2.9 Robolab is the newer programming environment originally used on the RCX programmable brick. Version 2.9 has been updated so that it can be used to program the NXT brick. Lego has announced that it will stop officially supporting Robolab but Robolab 2.9 is still available and there are still many user forums and other sources of help available.


RoboMind is educational software that is specially developed to teach students about logic, programming and robotics. The strength of RoboMind is the compactness of the learning environment, which allows to quickly develop and test scripts in a virtual environment. The scripts can then directly be transferred to a Lego Mindstorms NXT robot, to see the result in real life. RoboMind script run on the standard firmware.


Developed by the Carnegie Mellon Robotic's Academy, ROBOTC is a programming-language based on C for VEX, the new VEX Cortex, FIRST Tech Challenge, and Lego Mindstorms. ROBOTC runs a very optimized firmware which allows the NXT to run programs very quickly, and also compresses the files so that you can fit a large amount of programs into your NXT. Like other NXT languages, ROBOTC requires this firmware to be downloaded from the ROBOTC interface in order to run.


NXTGCC is a GCC toolchain for programming the NXT firmware in C.


leJOS NXJ is a high level open source language based on Java that uses custom firmware developed by the leJOS team.


To be able to write in C/C++, nxtOSEK can be used, but that requires custom firmware too.


To write files on the NXT itself, ICON by Steve Hassenplug is an ideal resource.

MATLAB and Simulink

  • MATLAB is a high-level programming language for numerical computing, data acquisition and analysis. It can be used to control LEGO NXT robots over a Bluetooth serial port (serial port communication is part of the base functionality of MATLAB) or via a USB connection; for example using the RWTH - Mindstorms NXT Toolbox (free & open-source).
  • Simulink is a MATLAB-based environment for modeling and simulating dynamic systems. Using Simulink, a user can design control algorithms, automatically generate C code for those algorithms, and download the compiled code onto the LEGO NXT. Support for programming the Lego NXT only requires SSimulink and is freely available.
MATLAB and Simulink Support for LEGO MINDSTORMS NXT programming is freely available. More information found at LEGO MINDSTORMS NXT Support from MATLAB and Simulink


pbLua is a port of the Lua programming language, a general purpose scripting language, for Lego Mindstorms.


A port of GNAT is available for the NXT. It relies on a dedicated run-time kernel based on the Ravenscar profile, the same used on the Goce satellite: this permits to use high-level Ada features to develop concurrent and real-time systems on the Mindstorms NXT.


URBI is yet another language and is a parallel and event-driven language, with interfaces to C++/Java and Matlab. It also has a component architecture (UObject) for distribution. Urbi is compatible with many robots, including Nao (cf Robocup), Bioloid or Aibo.

FLL NXT Navigation

FLL Nxt Navigation An open source program to help navigation on the FLL competition table. It uses NXT-G and .txt files to write programs. It is unknown if you can legally implement this in FLL competitions.


ruby-nxt is a library to program the NXT for the Ruby programming language. Unlike the other languages for the NXT the code is not compiled to a binary file. Instead the code is directly transmitted to the NXT via a Bluetooth connection.


Robotics.NXT is a Haskell interface to NXT over Bluetooth. It supports direct commands, messages and many sensors (also unofficial). It has also support for a simple message-based control of a NXT brick via remotely executed program (basic NXC code included).


LibNXT is a utility library for talking to the LEGO Mindstorms NXT intelligent brick at a relatively low level. LibNXT is targeted mainly at the platforms that the official Lego Mindstorms NXT software overlooks, namely Linux and other unices. It will work on any POSIX-compliant operating system where libusb 0.1 is supported. Windows support is also possible with the win32 port of libusb.


PyNXC is a project which converts Python code to "Not Exactly C" (NXC) code, to download to LEGO MINDSTORMS Robots.


NXT-Python is a python module, which communicates with the NXT via USB or Bluetooth. It supports direct commands and several aftermarket sensors.

Physical Etoys

A Lego NXT car which avoids walls implemented in Physical Etoys
Physical Etoys is a visual programming system for different electronic devices. It supports direct mode and compiled mode

No comments:

Post a Comment