Ecole Polytechnique Fédérale de Lausanne
english only

First Steps with the NXT

Robot building guides

Programming the brick

NBC/NXC is a C-like programming language designed for the Lego robots. It comes with a GUI for Windows. However, the command line version is easy to use under Linux.

USB file transfer

Compilation with nbc produces an executable file (.rxe) that needs to be transferred to the brick. Ideally, the compiler should do this for you when you don't specify an output file name; for me, it did'nt work and I used LiNXT instead.

LinXT Installation

  1. Install libusb libraries:
        sudo apt-get install libusb-dev libusb-0.1-4
  2. Install the perl module Device::USB:
        sudo cpan
          install Inline
          install Device::USB
  3. Download and extract LiNXT.
  4. Create a link to the binary:
        sudo ln -s ~/lego/linxt-0.1/linxt /usr/bin/linxt

Uploading files

Now you can upload files to the NXT brick:
        sudo linxt -u file.rxe
If the file was already present in My Files>Software files, the transfer fails.

Connecting via Bluetooth

  1. Install Bluetooth packages:
         sudo apt-get install bluez-utils bluez-pin
  2. Make sure Bluetooth on your computer is turned on, then start the services:
         sudo /etc/init.d/bluetooth start
  3. Now turn Bluetooth on NXT brick on and let your computer scan for it:
         hciconfig hci0
         hcitool scan
    You should get something like this:
         00:16:53:04:20:C9       NXT
  4. Create a file /etc/bluetooth/pin containing plaintext "1234". (This is the default pin on the NXT, you may change it).
         sdptool add --channel=3 SP   
         rfcomm listen /dev/rfcomm0 3
    The NXT should now be able to find your computer (Bluetoot>Search). You need to enter the pin to connect.
  5. To view the communication stream enter:
         cat /dev/rfcomm0 | od -t x1 -w1 -v -Ax