🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: be.comp.programming
1 messages
1 total messages Started by Gekkie Sun, 12 Mar 2006 13:02
timer
#806
Author: Gekkie
Date: Sun, 12 Mar 2006 13:02
198 lines
5780 bytes
Hallo,
Hier onder zie je een code staan voor iets te laten bewegen naar voor en 
achteuit links recht en schuins.
in het PRIVATE SUB DRI VEUP() zou ik een timer willen hebben die eerst het 
1ste pin voor software aan te spreken ( DO)  van een 25 pinnen poort 
aanstuurt
Dat deze enkele seconden blijft staan op Decimaal getal 1 daarna over gaat 
op decimaal getal 2.
thanxs




Option Compare Database
Private Declare Sub PortOut Lib "IO.DLL" (ByVal Port As Integer, ByVal Data 
As Byte)


Dim moving As Boolean
Dim turning As Boolean



Private Sub cmdRight_GotFocus()
    Me.cmdDrive.SetFocus
End Sub

Private Sub cmdstop_GotFocus()
    Me.cmdDrive.SetFocus
End Sub

Private Sub cmddown_GotFocus()
    Me.cmdDrive.SetFocus
End Sub


Private Sub cmdup_GotFocus()
    Me.cmdDrive.SetFocus
End Sub

Private Sub cmdleft_GotFocus()
    Me.cmdDrive.SetFocus
End Sub
Private Sub Form_Load()
    Me.cmdDown.Visible = False
    Me.cmdUp.Visible = False
    Me.cmdLeft.Visible = False
    Me.cmdRight.Visible = False
    Me.cmdStop.Visible = True
    Me.cmdDrive.SetFocus
    moving = False
    turning = False
End Sub

Private Sub cmdDrive_KeyUp(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case 97, 99, 100, 102, 103, 105: Call Center
        Case 98, 104: Call StopCar
    End Select
End Sub

Private Sub cmddrive_keydown(KeyCode As Integer, Shift As Integer)
    Debug.Print KeyCode

    Select Case KeyCode
        Case 97: Call GoLeftdown
        Case 98: Call GoBack
        Case 99: Call GoRightdown
        Case 100: Call GoLeft
        Case 102: Call GoRight
        Case 103: Call GoLeftUp
        Case 104: Call DriveUp
        Case 105: Call GoRightUp

    End Select


    ' Links achteruit = 97,
    ' Achteruit = 98,
    ' Rechts achteruit = 99,
    ' Links = 100,
    ' Rechts = 102,
    ' Links vooruit = 103,
    ' Vooruit = 104,
    ' Rechts vooruit = 105.
    Me.cmdDrive.SetFocus
End Sub

Private Sub GoLeftUp()
    If turning = False Then
        Call PortOut(&H378&, 17)
        Me.cmdLeft.Visible = True
        Me.cmdRight.Visible = False
        Me.cmdUp.Visible = True
        turning = True
    End If
End Sub
Private Sub GoLeftdown()
    If turning = False Then
        Call PortOut(&H378&, 20)
        Me.cmdLeft.Visible = True
        Me.cmdRight.Visible = False
        Me.cmdDown.Visible = True
        turning = True
    End If
End Sub
Private Sub GoRightUp()
    If turning = False Then
        Call PortOut(&H378&, 9)
        Me.cmdLeft.Visible = False
        Me.cmdUp.Visible = True
        Me.cmdRight.Visible = True
        turning = True
    End If
End Sub
Private Sub GoRightdown()
    If turning = False Then
        Call PortOut(&H378&, 12)
        Me.cmdLeft.Visible = False
        Me.cmdDown.Visible = True
        Me.cmdRight.Visible = True
        turning = True
    End If
End Sub


Private Sub GoLeft()
    Debug.Print "L"
    If turning = False Then
        Call PortOut(&H378&, 16)
        Me.cmdLeft.Visible = True
        Me.cmdRight.Visible = False
        turning = True
    End If
End Sub


Private Sub GoRight()
    Debug.Print "r"
    If turning = False Then
        Call PortOut(&H378&, 8)
        Me.cmdRight.Visible = True
        Me.cmdLeft.Visible = False
        turning = True
    End If
End Sub

Private Sub DriveUp()
    Debug.Print "UP"
    If moving = False Then

'Hier zou een timer of zoiets moeten staan voor de Call PortOut ( &H378&, 
1 ) die na enkele seconden gaat slapen of zo.
'Zodat deze niet meer gebruikt wordt en dan moet deze over gaan naar Call 
PortOut(&H378&, 2) zodat deze blijft gaan.



        Call PortOut(&H378&, 1)

        Call PortOut(&H378&, 2)


        Me.cmdStop.Visible = False
        Me.cmdDown.Visible = False
        Me.cmdUp.Visible = True
        moving = True

    End If

End Sub

Private Sub GoBack()
Debug.Print "A"
    If moving = False Then
        Call PortOut(&H378&, 4)
        Me.cmdStop.Visible = False
        Me.cmdDown.Visible = True
        Me.cmdUp.Visible = False
        moving = True
    End If
End Sub

Private Sub Center()
    Call StopCar
    Me.cmdRight.Visible = False
    Me.cmdLeft.Visible = False
    turning = False
End Sub

Private Sub StopCar()
    Debug.Print "STOP"
    Call PortOut(&H378&, 0)
    Me.cmdStop.Visible = True
    Me.cmdDown.Visible = False
    Me.cmdUp.Visible = False
    moving = False
End Sub
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads