Hi,
The android stuff is only in svn.
There shouldn't be too much difference between standard leJOS and android here (other than android can't do the robotic package).
The TachoCount example shows how to use motors:
- Code: Select all
public class TachoCount {
public static void main(String [] args) throws Exception {
NXTConnector conn = new NXTConnector();
conn.addLogListener(new NXTCommLogListener() {
public void logEvent(String message) {
System.out.println(message);
}
public void logEvent(Throwable throwable) {
System.err.println(throwable.getMessage());
}
});
conn.setDebug(true);
if (!conn.connectTo("btspp://NXT", NXTComm.LCP)) {
System.err.println("Failed to connect");
System.exit(1);
}
NXTCommand.getSingleton().setNXTComm(conn.getNXTComm());
System.out.println("Tachometer A: " + Motor.A.getTachoCount());
System.out.println("Tachometer C: " + Motor.C.getTachoCount());
Motor.A.rotate(5000);
Motor.C.rotate(-5000);
Thread.sleep(10000);
Sound.playTone(1000, 1000);
System.out.println("Tachometer A: " + Motor.A.getTachoCount());
System.out.println("Tachometer C: " + Motor.C.getTachoCount());
conn.close();
}
}
I'm not so sure about sensors via LCP but the PC examples has:
- Code: Select all
/**
* This is a test of remote reading of sensors from the PC
* using the iCommand equivalent classes in pccomm.jar
*
* @author Lawrie Griffiths
*
*/
public class SensorTest {
public static void main(String[] args) {
LightSensor light = new LightSensor(SensorPort.S1);
SoundSensor sound = new SoundSensor(SensorPort.S2);
TouchSensor touch = new TouchSensor(SensorPort.S3);
UltrasonicSensor sonic = new UltrasonicSensor(SensorPort.S4);
while(sound.readValue() < 90) {
System.out.println("light = " + light.readValue());
System.out.println("sound = " + sound.readValue());
System.out.println("touch = " + touch.isPressed());
System.out.println("distance = " + sonic.getDistance());
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {}
}
}
}
Give it a try and if that doesn't work, perhaps see the link below. Anyway, as I said using LCP should be the same for Android so any posts you see related to that should apply.
see
http://lejos.sourceforge.net/p_technologies/nxt/nxj/api/lejos/nxt/remote/RemoteNXT.htmlShawn