InputByte Method

int InputByte(int port)

Summary

This method retrieves the current input value of the specified digital I/O port on the device. When a port is configured as an input port (using the SetDirection Method), the input value represents the voltage levels on the port's pins. For each bit, a low voltage (close to 0V) yields a 0-bit in the input value and a high voltage (close to 5V) yields a 1-bit.

Parameters

  • port - Specifies the port number (0-5) to read.

Return Value

This method returns an integer. The return value is the current input value of the specified port.

Example
Eth32 dev = new Eth32();
int portval;

try
{
	// .... Your code that establishes a connection here
	
	// Read the input value of port 2
	portval=dev.InputByte(2);

	// See whether any of bits 0-3 are high (1)
	if( (portval & 0x0F) != 0 )
	{
		// At least one of bits 0-3 are high
	}
	else
	{
		// None of bits 0-3 are high
	}

}
catch (Eth32Exception e)
{
	// Handle Eth32 errors here
}
        
See Also

InputBit Method, InputByteByte Method, OutputByte Method, SetDirection Method