Article View: be.comp.programming
Article #806timer
From: Gekkie
Date: Sun, 12 Mar 2006 13:02
Date: Sun, 12 Mar 2006 13:02
198 lines
5780 bytes
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
Technical Details
Message-ID:
<J_SdnRTZt7FqhonZRVnyjg@scarlet.biz>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.scarlet.biz!news.scarlet.biz.POSTED!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: fcea4,d11ce82903815d,start X-Google-Attributes: gidfcea4,public X-Google-Language: DUTCH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.scarlet.biz!news.scarlet.biz.POSTED!not-for-mail NNTP-Posting-Date: Sun, 12 Mar 2006 07:02:47 -0600 From: "Gekkie" <gekkertje01@hotmail.com> Newsgroups: be.comp.programming Subject: timer Date: Sun, 12 Mar 2006 14:02:41 +0100 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2527 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 Message-ID: <J_SdnRTZt7FqhonZRVnyjg@scarlet.biz> Lines: 201 NNTP-Posting-Host: 62.235.114.120 X-Trace: sv3-An7kuqbGSOQH4lKv0YUNRlJSjdtk9RSe6Re/Tyk8M6nhkz0d94s9sdUN7ahxRNBJhHTWomdjKU2zqHf!Sdd8EjPTW4Gn6VB0deBm2TAb2Ssij76uuKMvqEbi05AXwrqRnS6XqCR/Z3AgH7/8wfhl3K7ZIjR9 X-Complaints-To: abuse@scarlet.be X-DMCA-Complaints-To: abuse@scarlet.biz X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32