I am trying to use the Parallax Ping))) ultrasonic sensor with a ioio V1 board, using the IOIO00503 library. I get a good looking signal...see the attached scope view, but the input.getDuration() call returns 16.8 micro seconds most of the time, called 2 times per second. Every once in a while I get the proper number.
Any ideas? Here is the code:
import ioio.lib.api.DigitalOutput;
import ioio.lib.api.IOIO;
import ioio.lib.api.PulseInput;
import ioio.lib.api.PulseInput.PulseMode;
import ioio.lib.api.exception.ConnectionLostException;
public class UltraSonicSensors
{
private static final int LEFT_ULTRASONIC_INPUT_PIN = 35;
private static final int LEFT_STROBE_ULTRASONIC_OUTPUT_PIN = 15;
private final PulseInput leftInput;
private DigitalOutput leftStrobe;
private float leftDistance;
private IOIO ioio;
public UltraSonicSensors(IOIO ioio) throws ConnectionLostException
{
this.leftInput = ioio.openPulseInput(LEFT_ULTRASONIC_INPUT_PIN, PulseMode.
POSITIVE);
this.leftStrobe = ioio.openDigitalOutput(LEFT_STROBE_ULTRASONIC_OUTPUT_PIN
);
this.ioio = ioio;
}
public void read() throws ConnectionLostException, InterruptedException
{
read(leftStrobe, leftInput);
}
private void read(DigitalOutput strobe, PulseInput input)
throwsConnectionLostException, InterruptedException
{
ioio.beginBatch();
strobe.write(true);
strobe.write(false);
ioio.endBatch();
this.leftDistance = input.getDuration();
}
public float getLeftDistance()
{
return leftDistance;
}
}
--
You received this message because you are subscribed to the Google Groups
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.
<<attachment: TEK0000.JPG>>
