I'm currently trying to hook up a Sharp GP2Y0A21YK sensor (Datasheet) directly to the NXT. I took the configuration of the different wires in a NXT sensor/motor cable from here: http://www.roberta-home.de/sites/defaul ... v1-1_0.pdf (German), page 17 (or page 9 as printed on the page). The document says the first wire (white) of the cable is used as analog input. I supposed to be able to measure the voltage this way. But using the following code, I just get values of -1:
- Code: Select all
import lejos.nxt.ADSensorPort;
public class SharpIRSensor {
private ADSensorPort port;
public SharpIRSensor(ADSensorPort port) {
this.port = port;
}
public int getRaw() {
return port.readRawValue();
}
}
Is my approach wrong in general or am I just using the API wrong?
