constructor Motor undefined

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

constructor Motor undefined

Postby hannes11 » Sun Dec 04, 2011 10:55 am

i am using eclipse with plugin and lejos 0.9.0 beta. in the following programm the compiler gives the error:
the "constructor Motor(MotorPort) is undfined" and then so on. it doesn´t matter to compile out eclispe or in the command box. i think all the enviroment varialbe are set accurately.

import lejos.nxt.*;

class Quadrat {
Motor motorA = new Motor(MotorPort.A);
Motor motorB = new Motor(MotorPort.B);
Quadrat() throws Exception {
int i = 0;
while (i < 4) {
motorA.setSpeed(300);
motorA.forward();
motorB.setSpeed(300);
motorB.forward();
Thread.sleep(5000);
motorA.stop();
motorB.stop();
motorA.rotate(-180, true);
motorB.rotate(180);
i++;
}
motorA.stop();
motorB.stop();
}

public static void main(String[] args) throws Exception {
new Quadrat();
}
}

thanx for answers,
hannes
hannes11
New User
 
Posts: 1
Joined: Sun Dec 04, 2011 10:43 am

Re: constructor Motor undefined

Postby skoehler » Sun Dec 04, 2011 1:35 pm

Please consult the documentation:http://lejos.sourceforge.net/nxt/nxj/api/index.html
Motor has no constructor that allows for an argument. (In fact, Motor should not have any constructor at all).
Here's what you should replace your two lines with:

NXTRegulatedMotor motorA = Motor.A;
NXTRegulatedMotor motorB = Motor.B;
skoehler
leJOS Team Member
 
Posts: 1458
Joined: Thu Oct 30, 2008 4:54 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 4 guests

more stuff