com.dexterind.gopigo.components
Class UltraSonicSensor

java.lang.Object
  extended by com.dexterind.gopigo.components.UltraSonicSensor

public class UltraSonicSensor
extends java.lang.Object

It get access to the ultrasonic sensor distance calculation. It also allows to enable or disable it.

Author:
marcello

Field Summary
private static Board board
          The main object which handles the methods to get access to the resources connected to the board.
private  Debug debug
          The debug object.
private static UltraSonicSensor instance
          The instance of the current object.
private  int pin
          The current pin.
 
Constructor Summary
UltraSonicSensor()
           
 
Method Summary
 int getDistance()
          Reads the distance through the ultrasonic sound.
static UltraSonicSensor getInstance()
          Provides a global point of access to the UltraSonicSensor instance.
 void setPin(int pin)
          Sets the pin to use for the sensor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

board

private static Board board
The main object which handles the methods to get access to the resources connected to the board.


instance

private static UltraSonicSensor instance
The instance of the current object.


pin

private int pin
The current pin. It can be configured through the setPin() method.


debug

private Debug debug
The debug object.

Constructor Detail

UltraSonicSensor

public UltraSonicSensor()
                 throws java.io.IOException,
                        java.lang.InterruptedException
Throws:
java.io.IOException
java.lang.InterruptedException
Method Detail

getInstance

public static UltraSonicSensor getInstance()
                                    throws java.io.IOException,
                                           java.lang.InterruptedException
Provides a global point of access to the UltraSonicSensor instance.

Returns:
the UltraSonicSensor instance.
Throws:
java.io.IOException
java.lang.InterruptedException

setPin

public void setPin(int pin)
Sets the pin to use for the sensor.

Parameters:
pin - The number of the pin where the sensor is attached.

getDistance

public int getDistance()
                throws java.io.IOException
Reads the distance through the ultrasonic sound.

Returns:
The distance in centimeters.
Throws:
java.io.IOException