Working simple java code


#1

Hello
I am trying for the first time to work with the BrickPi, using Java.
I have MindStorm (v1) and rpi B.
I’ve written simple code in java using BrickPiJava, but the motor doesn’t move (I do here a very quite noise from it):

log("Starting.");
BrickPi brickPi = BrickPi.getBrickPi();
log("Got brick.");
brickPi.setTimeout(20000);
brickPi.setupSensors();
// Thread.sleep(1000);
log("Setup sensors.");

Motor leftWheel = new Motor();
brickPi.setMotor(leftWheel, 0);

leftWheel.setCommandedOutput(200);
leftWheel.setEnabled(true);
leftWheel.setCommandedOutput(-25);
// leftWheel.rotate(10, 50);
log("Motor " + i + " rotated!");

Thread.sleep(10000);

log("Done.");

Am I missing something? the BrickPiTests main also couldn’t move the motor.


#2

Hello reformy,

you should expect to be asked, how do you power the BrickPi. Do you use batteries or external power supply 9V attached to BrickPi?


#3

Thanks.
I forgot to say.
Since powering the RPI with micro USB from the wall didn’t work, I’ve tried an ADDITIONAL 9V battery to the brickpi.
No luck there too.


#4

So, I just wonder, have you tried the Python or C examples just to make sure that is not Java interface/code that is source of trouble?


#5

Thanks.
I’ve just ran the browser bot in Python, and it worked well.
I guess the problem is with the Java part.
Can anyone send me a sample project that rotate one motor?