Paso 6: Código VB
Copie el siguiente código:
Las importaciones de System.IO
Las importaciones System.IO.Ports
Las importaciones System.Threading
Public Class Form1
_Continue compartido como Boolean
Compartido _serialPort SerialPort
Privada Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) maneja MyBase.Load
SerialPort1.Close()
SerialPort1.PortName = "com3″ ' cambiar el puerto com para que coincida con tu Arduino puerto importante
SerialPort1.BaudRate = 9600
SerialPort1.DataBits = 8
SerialPort1.Parity = Parity.None
SerialPort1.StopBits = StopBits.One
SerialPort1.Handshake = Handshake.None
SerialPort1.Encoding = System.Text.Encoding.Default
End Sub
Privada Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) maneja Button1.Click, Button1.Click
SerialPort1.Open()
SerialPort1.Write("1″)
SerialPort1.Close()
End Sub
Privada Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) maneja Button2.Click
SerialPort1.Open()
SerialPort1.Write("0″)
SerialPort1.Close()
End Sub
Privada Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) maneja Button3.Click
SerialPort1.Open()
SerialPort1.Write("3″)
SerialPort1.Close()
End Sub
Privada Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) maneja Button4.Click
SerialPort1.Open()
SerialPort1.Write("4″)
SerialPort1.Close()
End Sub
Clase final