Programación en Visual Basic 2010
Programación en Visual Basic 2010
Programación en Visual Basic 2010
Imports System
Imports System.Threading
Imports System.IO.Ports
Imports System.ComponentModel
Public Class Form1
Dim myPort As Array
Delegate Sub SetTextCallback(ByVal Form1 As String)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
myPort = IO.Ports.SerialPort.GetPortNames()
ComboBox1.Items.AddRange(myPort)
Button2.Enabled = False
Button1.Enabled = False
Button4.Enabled = False
Label10.Text = "OFF"
Button5.Enabled = False
Button6.Enabled = False
Button3.Enabled = False
Button7.Enabled = False
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown, Button1.KeyUp,
Button1.KeyDown, Button4.KeyDown, Button3.KeyDown, Button2.KeyDown,
Button7.KeyDown
If e.KeyCode = Keys.F Then
Button1.PerformClick()
End If
If e.KeyCode = Keys.B Then
Button2.PerformClick()
End If
If e.KeyCode = Keys.C Then
Button3.PerformClick()
End If
If e.KeyCode = Keys.V Then
Button4.PerformClick()
End If
If e.KeyCode = Keys.X Then
Button7.PerformClick()
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button5.Click
SerialPort1.PortName = ComboBox1.Text
SerialPort1.BaudRate = ComboBox2.Text
SerialPort1.Open()
Button5.Enabled = False
Button1.Enabled = True
Button2.Enabled = True
Label10.Text = "ON"
Button3.Enabled = True
Button4.Enabled = True
Button6.Enabled = True
Button7.Enabled = True
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button6.Click
SerialPort1.Close()
Button5.Enabled = True
Button1.Enabled = False
Button2.Enabled = False
Label10.Text = "OFF"
Button3.Enabled = False
Button4.Enabled = False
Button6.Enabled = False
Button7.Enabled = False
Label11.Text = "-"
Label12.Text = "-"
Label13.Text = "-"
Label14.Text = "-"
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ComboBox2.SelectedIndexChanged
Button5.Enabled = True
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
SerialPort1.Write("I")
Label11.Text = "Encendido"
Label13.Text = "Encendido"
Label14.Text = "Derecha"
Label12.Text = "Derecha"
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button4.Click
SerialPort1.Write("S")
Label13.Text = "Encendido"
Label11.Text = "Encendido"
Label14.Text = "Izquierda"
Label12.Text = "Derecha"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
SerialPort1.Write("R")
Label11.Text = "Encendido"
Label13.Text = "Encendido"
Label12.Text = "Izquierda"
Label14.Text = "Derecha"
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Button2.Click
SerialPort1.Write("J")
Label11.Text = "Encendido"
Label13.Text = "Encendido"
Label14.Text = "Izquierda"
Label12.Text = "Izquierda"
End Sub
atras:
high B.1,3
'pause 1000
'low B.1,3
goto inicio
izquierda:
high B.0,3
'pause 1000
'low B.0,3
goto inicio
derecha:
high B.2,1
'pause 1000
'low B.2,1
goto inicio
apagado:
'low B.0,1,2,3
goto inicio