The other day i was playing around with Visual Basic 2008,and i cam up with a cool little program for my pan and tilt system,Wherever the mouse moves,the pan and tilt move. here is a little picture of it
http://i122.photobucket.com/albums/o255/wowy5/I1.jpg
if anyone wants to know the source code for it,Here it is
Public Class Form1
Dim p As Integer = 0
Dim p2 As Integer
Dim label As New Label
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Escape Then
SerialPort1.WriteLine("#16 P1500 S2225 <cr>" & vbCrLf & vbCrLf)
SerialPort1.WriteLine("#22 P1500 S2225 <cr>" & vbCrLf & vbCrLf)
End
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If SerialPort1.IsOpen = False Then
SerialPort1.Open()
End If
End Sub
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
Try
SerialPort1.WriteLine("#22 P" & e.X * 1.2 & " S" & p & " <cr>" & vbCrLf & vbCrLf)
SerialPort1.WriteLine("#16 P" & e.Y * 2 & " S" & p & " <cr>" & vbCrLf & vbCrLf)
Label1.Text = "X : " & e.X * 1.2
Label2.Text = "Y : " & e.Y * 2
Catch ex As Exception
SerialPort1.Write("Cannot Find SSC-32!")
End Try
End Sub
Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
If e.Delta = 120 Then
p = p + 10
ElseIf e.Delta = -120 Then
p = p - 10
End If
Label3.Text = "Speed : " & p
ProgressBar1.Value = p
End Sub
End Class
- Brandon C.