'set port to 00000000
vbOut 888, 0
'set port to 10000000
vbOut 888, 1
'set port to 01000000
vbOut 888, 2
'set port to 00100000
vbOut 888, 4
'set port to 00010000
vbOut 888, 8
' sätt port 1
OutPort 888, 1
' slå av port 1
OutPort 888, -1
' hämta statusrad
PortNum%=vbInp(889)
Sub OutPort(PortAddress%, OutNum%)
PortState% = vbInp(PortAddress%)
PortNum% = PortState% + OutNum%
vbOut PortAddress%, PortNum%
If OutNum% = 0 Then vbOut PortAddress%, 0
End Sub
' status
Function BitStatus(PortAddress%, BitYouWant%) AS INTEGER
If PortAddress% = 888 THEN
NumOfBits% = 8
Else If PortAddress% = 889 Then
NumOfBits% = 5
Else
NumOfBits% = 4
Redim PortBits(NumOfBits%) As Integer
PortNum% = vbInp(PortAddress%)
For i = 1 To NumOfBits%
PortBits%(i) = PortNum% MOD 2
PortNum% = FIX(PortNum% / 2)
Next I
End If
BitStatus% = PortBits%(BitYouWant%)
End Function
' att läsa bit 5 på port 888
Bit5Variable% = BitStatus%(888, 5)