Due to the limited possibilities you have with the Lego Mindstorms software I just converted to the leJOS Java Virtual Machine and also flashed the NXT brick with the corresponding firmware.
I think it will give me much more options in coding functionalities. In addition to that I’m using the Eclipse JDK. The firmware flashing and installation of the leJOS was very quick but I have to admit that the correct Eclipse setup took quite a while. It’s just because I never used it before.
As this is all done now I’ll set up the first projects. Below you’ll find my first sample:
package tospinout;
import lejos.nxt.*;
/**
* 2008-12-26 author 2spinout
*/
public class Cat
{
public static void main (String[] aArg)
throws Exception
{
// PortA = Motor.A = ultrasonic movement motor
// PortB = Motor.B = left driving motor
// PortC = Motor.C = right driving motor
// Port1 = SoundSensor
// Port2 = LightSensor
// Port3 = TouchSensor
// Port4 = UltrasonicSensor
LCD.drawString("2spinout",3,4);
Thread.sleep(2000);
Motor.B.setSpeed(720);// 2 RPM
Motor.C.setSpeed(720);
Motor.B.forward();
Motor.C.forward();
Thread.sleep (5000);
Motor.B.stop();
Motor.C.stop();
}
}
No comments:
Post a Comment