All pastes #814755 Raw Edit

robotics templates

public text v1 · immutable
·published 2007-12-13 15:13 UTC
rendered paste body
Option Explicit
Dim n As Integer
Dim BaseAddress As Integer

Private Declare Function Inp Lib "inpout32.dll" _
Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Private Declare Sub Out Lib "inpout32.dll" _
Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)


Private Function parallelput(n As Integer)
    Out BaseAddress, n
End Function
Private Function parallelget()
    parallelget = (Inp(BaseAddress + 1) Xor &H90)
End Function
Private Sub Delay(n As Single)
    Dim Start
    Dim Check
    Start = Timer
    Do Until Check >= Start + n * 0.001
        Check = Timer
    Loop
End Sub
Public Function controlput(n As Integer)
    Out (BaseAddress + 2), n Xor &HB
End Function
Public Function controlget()
    controlget = (Inp(BaseAddress + 2) Xor &HB)
End Function
Private Sub cmdParallel1_Click()
 parallelput (1)
End Sub

Private Sub Command1_Click()
For n = 1 To 9
parallelput (n + 16)
Delay (500)
Next
End Sub

Private Sub cmdback_Click()
parallelput (2 + 4)
End Sub

Private Sub cmdforward_Click()
parallelput (1 + 8)
End Sub

Private Sub cmdleft_Click()
parallelput (1)
End Sub

Private Sub cmdright_Click()
parallelput (2)
End Sub

Private Sub cmdstop_Click()
parallelput (0)
End Sub

Private Sub Form_Load()
 BaseAddress = &H378  'Go to Control panel to find the address
End Sub
Private Sub Timer1_Timer()
  n = n + 1
  If n Mod 2 = 0 Then
    parallelput (1)
  Else
    parallelput (0)
   End If
End Sub
Private Sub Timer2_Timer()
parallelput (2)
End Sub