InputByte Method

Public Function InputByte(ByVal port As Long) As Long

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 a Long. The return value is the current input value of the specified port.

Example
Private Sub example()
    Dim portval As Long

    ' Set up error handling for this routine
    On Error GoTo myerror
    
    Set dev = New Eth32
    
    ' .... 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 And &H0F) <> 0 Then
        ' At least one of bits 0-3 are high
    Else
        ' None of bits 0-3 are high
    End If


    
    Exit Sub
myerror:
    MsgBox "ETH32 error: " & dev.ErrorString(Err.Number)
End Sub
        
See Also

InputBit Method, OutputByte Method, SetDirection Method