The oCompassVX Object uses the 5 I/O lines specified by the IOGroup property to read a Vector 2X Compass Module and return a URCP Heading value of -128 to +127.
In the following example, the oCompassVX Object is used to detect the direction that the Vector 2X compass Module is facing and displays that direction as a binary number on I/O group 1.
Visual Basic Syntax
C and Java Syntax
' This program reads a Vector 2X compass
' Module and displays the binary
' result on I/O Lines 8 - 15.
Dim C As New oCompassVX
Dim D As New oDIO8
Sub Main()
C.IOGroup = 3
C.Operate = cvTrue
D.IOGroup = 1
D.Direction = cvOutput
Do
D.Value = C.Value
Loop
End Sub
// This program reads a Vector 2X compass
// Module and displays the binary
// result on I/O Lines 8 - 15.
oCompassVX C = New oCompassVX;
oDIO8 D = New oDIO8;
Void Main(Void){
C.IOGroup = 3;
C.Operate = cvTrue;
D.IOGroup = 1;
D.Direction = cvOutput;
Do{
D.Value = C.Value;
} While (1);
}
Basic Syntax
' This program reads a Vector 2X compass
' Module and displays the binary
' result on I/O Lines 8 - 15.
C As oCompassVX(3,cvon)
D As oDIO8(1,cvOutput)
D.IOGroup = 1
D.Direction =
Do
D.Value = C.Value
Loop