Professional Documents
Culture Documents
Written by JCLarsen Thursday, 04 September 2008 10:17 - Last Updated Monday, 22 August 2011 09:46
When you want to use NXC on Linux, you can not use the BrixcCC. You will have to download a compiler, to compile the programming, and a communication tool for sending the programs to the NXT. This guide is describing the way of downloading the compiler and the comminication tool, and how to make it work on Ubuntu.
The NBC compiler can be downloaded from the Bricxcc web site.
First we download the NBC compiler to the directory you wan't to install it to
$ wget http://downloads.sourceforge.net/bricxcc/nbc-1.2.1.r4.tgz
$ mkdir nbc
$ cd nbc/NXT
1/5
$ ./nbc
Next Byte Codes Compiler version 1.2 (1.2.1.r4, built Tue Mar 15 16:10:49 CDT 2011)
Use "nbc -help" for more information. You then move it to /usr/local/bin
$ nano hello.nxc
task main() {
2/5
Wait(1000);
Hopefully you will only see the file "hello.rex" being created and no messages being printed in the terminal.
3/5
Create a new file called 45-legonxt.rules in /etc/udev/rules.d, using your favorite editor
In this file youinsertthe following content: SUBSYSTEM=="usb_device", ACTION=="add", SYSFS{idVendor}=="0694", SYSFS{idProduct}=="0002", SYMLINK+="legonxt-%k", GROUP="legonxt", MODE="0660", RUN+="/etc/udev/legonxt.sh" You then create a file called legonxt.sh in /etc/udev, using your favorite editor
In this file you insert the following centent: #!/bin/bash # GROUP=legonxt if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ] then chmod o-rwx "${DEVICE}" chgrp "${GROUP}" "${DEVICE}" chmod g+rw "${DEVICE}" fi To make sure the script is executable run the following command
$ sudo chmod a+x /etc/udev/legonxt.sh This should do the trick. Now you have to reboot to make it work. Compiling
and
4/5
Now with everything in place and working is it now possible to compile and program the NXT in one process with the following command. In this example, the program that should be downloaded to the NXT brick is called hello.nxc.
$nbc hello.nxc -sm- -d -S=usb If you also would like to have the NXT brick to start the program after it have been downloaded the command are the following: $ nbc hello.nxc -sm- -r -S=usb
Documentation
Now this compiling and communication for the NXT is working (hopefully). To get into the programming I will recommend the following material: - The " Programming Lego Robots using NXC ", by Danny Benedettelli - A simple getting started guide. - The " NXC_Guide.pdf " - This is a really comprehensive guide that have all the details about NBC/NCX.
Examples
Follow the link(s) below to get some example code to get started with - Tutorial code by Danny Bennedettelli click her
5/5