Joystick

M:\Mike (latest)\Stub Programs\Advanced Joystick - doneprinter\Joystick.frm
File saved: 4/6/2006 10:52:32 PM
Generated: 4/30/2006 4:52:06 PM

Table of Contents
(Designer Object Definition)
Declarations
Center_Click
Dance1_Click
Form_Load
Load_Channels
Forward_Click
Left_Click
leftmid_Click
Reverse_Click
Right_Click
rightmid_Click
SEND_Click
STOP_Click
Move_Servo
threesixtyleft_Click
threesixtyright_Click
Form_Unload


VERSION 5.00 Table of Contents Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX" Begin VB.Form Joystick Caption = "Form2" ClientHeight = 4830 ClientLeft = 165 ClientTop = 735 ClientWidth = 6015 LinkTopic = "Form2" ScaleHeight = 4830 ScaleWidth = 6015 StartUpPosition = 3 'Windows Default Begin VB.ComboBox CHANNEL Height = 315 Left = 960 TabIndex = 13 Text = "Combo1" Top = 360 Width = 855 End Begin VB.TextBox POSITION Height = 285 Left = 960 TabIndex = 12 Text = "Text2" Top = 960 Width = 975 End Begin VB.ListBox OUT Height = 1035 Left = 3480 TabIndex = 11 Top = 2640 Width = 2175 End Begin VB.CommandButton SEND Caption = "Send Data to RS232" Height = 495 Left = 2160 TabIndex = 10 Top = 600 Width = 975 End Begin VB.CommandButton Forward Caption = "Forward" Height = 495 Left = 960 TabIndex = 9 Top = 2640 Width = 735 End Begin VB.CommandButton Left Caption = "Left 2" Height = 495 Left = 120 TabIndex = 8 Top = 3000 Width = 735 End Begin VB.CommandButton Right Caption = "Right 2" Height = 495 Left = 1800 TabIndex = 7 Top = 3000 Width = 735 End Begin VB.CommandButton STOP BackColor = &H000000FF& Caption = "STOP" BeginProperty Font Name = "MS Sans Serif" Size = 24 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 1095 Left = 3480 MaskColor = &H000000FF& Style = 1 'Graphical TabIndex = 6 Top = 360 Width = 2295 End Begin VB.CommandButton Reverse Caption = "Reverse" Height = 495 Left = 960 TabIndex = 5 Top = 3840 Width = 735 End Begin VB.CommandButton Center Caption = "Center" Height = 495 Left = 960 TabIndex = 4 Top = 3240 Width = 735 End Begin VB.CommandButton threesixtyleft Caption = "360 L" Height = 495 Left = 120 TabIndex = 3 Top = 2160 Width = 735 End Begin VB.CommandButton threesixtyright Caption = "360 R" Height = 495 Left = 1920 TabIndex = 2 Top = 2160 Width = 735 End Begin VB.CommandButton leftmid Caption = "Left 4" Height = 495 Left = 120 TabIndex = 1 Top = 3600 Width = 735 End Begin VB.CommandButton rightmid Caption = "Right 4" Height = 495 Left = 1800 TabIndex = 0 Top = 3600 Width = 735 End Begin MSCommLib.MSComm Comm Left = 4680 Top = 3840 _ExtentX = 1005 _ExtentY = 1005 _Version = 393216 DTREnable = -1 'True End Begin VB.Line Line7 BorderWidth = 3 X1 = 0 X2 = 6000 Y1 = 240 Y2 = 240 End Begin VB.Line Line3 BorderWidth = 3 X1 = 0 X2 = 2760 Y1 = 2040 Y2 = 2040 End Begin VB.Line Line4 BorderWidth = 3 X1 = 2760 X2 = 6000 Y1 = 2040 Y2 = 2040 End Begin VB.Line Line1 BorderWidth = 3 X1 = 0 X2 = 6000 Y1 = 4440 Y2 = 4440 End Begin VB.Label Label1 Caption = "Channel" Height = 255 Left = 120 TabIndex = 18 Top = 360 Width = 855 End Begin VB.Label Label3 Caption = "Position" Height = 255 Left = 120 TabIndex = 17 Top = 960 Width = 615 End Begin VB.Label Label5 Caption = "Outgoing Commands" Height = 255 Left = 3600 TabIndex = 16 Top = 1800 Width = 2055 End Begin VB.Label Label4 Alignment = 2 'Center Caption = "Joystick Controls" Height = 255 Left = 0 TabIndex = 15 Top = 1800 Width = 2775 End Begin VB.Line Line6 BorderWidth = 3 X1 = 3240 X2 = 3240 Y1 = 2160 Y2 = 240 End Begin VB.Label Label7 Alignment = 2 'Center Caption = "Single Servo Control (testing)" Height = 255 Left = 0 TabIndex = 14 Top = 0 Width = 3255 End Begin VB.Line Line5 BorderWidth = 3 X1 = 0 X2 = 6000 Y1 = 1680 Y2 = 1680 End Begin VB.Line Line2 BorderWidth = 3 X1 = 3240 X2 = 3240 Y1 = 2040 Y2 = 4440 End Begin VB.Menu menu_file Caption = "File" Begin VB.Menu menu_close Caption = "Exit" End End End
Attribute VB_Name = "Joystick" Table of Contents Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Center_Click() Table of Contents 'center the wheels Call Move_Servo(2) OUT.AddItem "Center WHeels" End Sub
Private Sub Dance1_Click() Table of Contents '================================================= ' Dance one involves 360's and straight lines ' It will go for a random pause between 2 and 6 ' seconds then go straight for a random time between ' 1 and 3 seconds for 10 interations '================================================= Dim i As Integer Dim value As Integer For i = 0 To 10 value = Rnd Mod 6 Call Forward_Click Sleep (value * 1000) value = Rnd Mod 2 If value >= 1 Then value = Rnd Mod 3 Call threesixtyright_Click Sleep (value * 1000) Else value = Rnd Mod 3 Call threesixtyleft_Click Sleep (value * 1000) End If Next i End Sub
Private Sub Form_Load() Table of Contents Call Load_Channels ' RATE.Text = "" POSITION.Text = "" 'Needed or the program dies 'Comm.CommPort = 1 'Comm.PortOpen = True End Sub
Private Sub Load_Channels() Table of Contents CHANNEL.AddItem "0" CHANNEL.AddItem "1" CHANNEL.AddItem "2" CHANNEL.AddItem "3" CHANNEL.AddItem "4" CHANNEL.AddItem "5" CHANNEL.AddItem "6" CHANNEL.AddItem "7" CHANNEL.Text = "0" End Sub
Private Sub Forward_Click() Table of Contents Call Move_Servo(1) OUT.AddItem "Going Forward" End Sub
Private Sub Left_Click() Table of Contents 'Turn the wheels left Call Move_Servo(4) OUT.AddItem "Left 2wheels" End Sub
Private Sub leftmid_Click() Table of Contents 'Turn the wheels left Call Move_Servo(8) OUT.AddItem "Left 4wheels" End Sub
Private Sub Reverse_Click() Table of Contents 'Center the wheels Call Move_Servo(3) OUT.AddItem "Going Backwards" End Sub
Private Sub Right_Click() Table of Contents 'Turn the wheels Right Call Move_Servo(5) OUT.AddItem "Right 2wheels" End Sub
Private Sub rightmid_Click() Table of Contents 'Turn the wheels Right Call Move_Servo(9) OUT.AddItem "Right 4wheels" End Sub
Private Sub SEND_Click() Table of Contents Comm.Output = "33" + " " + CHANNEL.Text + " " + POSITION.Text + " " + "44" + " " OUT.AddItem "ind. sero adjusted" End Sub
Private Sub STOP_Click() Table of Contents Call Move_Servo(0) OUT.AddItem "Stopping" End Sub
Private Function Move_Servo(movee As String) Table of Contents 'Send the command to the robot to do whatever built in movement is required Comm.Output = "11" + " " + movee + " " + " " + "0" + " " + "22" + " " Sleep (50) End Function
Private Sub threesixtyleft_Click() Table of Contents 'Position the tires Call Move_Servo(6) OUT.AddItem "360 Left" End Sub
Private Sub threesixtyright_Click() Table of Contents 'Position the tires Call Move_Servo(7) OUT.AddItem "360 Right" End Sub
Private Sub Form_Unload(Cancel As Integer) Table of Contents Comm.PortOpen = False Sleep (1000) Unload Me End Sub