Start of Tutorial > Start of Trail |
The following instructions, which refer to the Linux platform, will
help you to run your first leJOS program.
We presume that you are familiar with the Java language on an
elementary level at least. If this is not the case, we encourage you to
consult the first trails of the The Java
Tutorial provided by Sun Microsystems.
Besides the LEGO MINDSTORMS RCX, the associated IR Tower and the leJOS environment (see below), you will need:
export LEJOS_HOME=your lejos directory
export PATH=$PATH:$LEJOS_HOME/bin
export
CLASSPATH=$CLASSPATH:.:$LEJOS_HOME/lib/classes.jar:$LEJOS_HOME/lib/pcrcxcomm.jar
export RCXTTY=com1
or export
RCXTTY=/dev/usb/legousbtower0
. bin
and in the release
folder.ant
. This will build the leJOS executables and
libraries on your Linux machine.bin
directory of
your leJOS installationfirmdl
If the download doesn't work,
make sure that
lejosfirmdl
.
The original LEGO® firmware
isn't deleted from the RCX, but stored away. Hence you may re-activate
it by just removing the batteries for some minutes and replacing it.
The leJOS firmware will be lost in this case, though, and will have to
be downloaded again to be useable on the RCX.
Note that you have to install the leJOS firmware only once (unless
removing the batteries); nevertheless it may be downloaded as often as
you wish, but the leJOS programs you have installed will be lost in
this case.
import josx.platform.rcx.*;
public class DistributionSmokeTest
{
public static void main (String[] args) throws Exception
{
LCD.clear();
TextLCD.print ("SMOKE");
Thread.sleep(1000);
TextLCD.print ("TEST");
Thread.sleep(1000);
}
}
To run this program, you will:
check
directory of your leJOS installationlejosjc
:lejosjc Distribution
SmokeTest
.java
lejos
:lejos
DistributionSmokeTest
lejosc
or lejos
isn't found, make sure
your PATH variable is set accordingly. Congratulations! You have run your first leJOS program on your RCX.
Yet, if it doesn't, feel free to post your question to the lejos discussion list.
Start of Tutorial > Start of Trail |