2.-Ahora Con Dos Botones y Dos LED: Visual Basic 2010
2.-Ahora Con Dos Botones y Dos LED: Visual Basic 2010
Imports System.IO.Ports
Imports System.Threading
Public Class Form1
Dim cambio12 As Boolean = True
Dim cambio13 As Boolean = True
Private Sub Form1_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
SerialPort1.Close()
SerialPort1.PortName = "com3" 'CAMBIA EL
PUERTO COM
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
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
SerialPort1.Open()
If cambio13 = True Then
SerialPort1.Write("13 on")
Else
SerialPort1.Write("13 off")
End If
cambio13 = Not (cambio13)
SerialPort1.Close()
End Sub
Private Sub Button2_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
SerialPort1.Open()
If cambio12 = True Then
SerialPort1.Write("12 on")
Else
SerialPort1.Write("12 off")
End If
cambio12 = Not (cambio12)
SerialPort1.Close()
End Sub
End Class
Programa para el
Arduino
char inData[20]; // Allocate some
space for the string
char inChar=-1; // Where to store
the character read
byte index = 0; // Index into
array; where to store the
character
void setup() {
Serial.begin(9600);
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
}
char Comp(char* This) {
while (Serial.available() > 0) //
Don't read unless
// there you know there is data
{
if(index < 19) // One less than the
size of the array
{
inChar = Serial.read(); // Read a
character
inData[index] = inChar; // Store it
index++; // Increment where to
write next
Visual Basic
' VISUAL BASIC 2010 (dos Button y un
SerialPort)
' Programa realizado por Juan Antonio
Villalpando
' [email protected]
Imports System.IO.Ports
Imports System.Threading
Public Class Form1
Dim cambio12 As Boolean = True
Dim cambio13 As Boolean = True
Private Sub Form1_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
SerialPort1.Close()
SerialPort1.PortName = "com3" 'CAMBIA EL
PUERTO COM
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
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
SerialPort1.Open()
If cambio13 = True Then
SerialPort1.Write("1")
Else
SerialPort1.Write("2")
End If
cambio13 = Not (cambio13)
SerialPort1.Close()
End Sub
Private Sub Button2_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
SerialPort1.Open()
If cambio12 = True Then
SerialPort1.Write("3")
Else
SerialPort1.Write("4")
End If
cambio12 = Not (cambio12)
SerialPort1.Close()