Digital input/output

If your IO line is configured as digital output, you can set its state (high/low) easily. All the XBee device classes provide the method, setDIOValue(IOLine, IOValue), with the desired IO line as the first parameter and an IOValue as the second. The IOValue enumerator includes HIGH and LOW as possible values.

Setting digital output values

[...]

// Set the DIO2_AD2 line low.
myXBeeDevice.setDIOValue(IOLine.DIO2_AD2, IOValue.LOW);

// Set the DIO2_AD2 line high.
myXBeeDevice.setDIOValue(IOLine.DIO2_AD2, IOValue.HIGH);

[...]

The setDIOValue() method may fail for the following reasons:

You can also read the current status of the pin (high/low) by issuing the method getDIOValue(IOLine). The parameter of the method must be the IO line to be read.

Reading digital input values

[...]

// Get the value of the DIO2_AD2.
IOValue value = myXBeeDevice.getDIOValue(IOLine.DIO2_AD2);

[...]

Handling DIO IO Lines example

The XBee Java Library includes two sample applications that demonstrate how to handle DIO lines in your local and remote XBee Devices. The examples are located in the following path:

/examples/io/LocalDIOSample

/examples/io/RemoteDIOSample