momentary switch with Visual Basic

He He i had a little error but it,s fixed :smiley: if someone needs the code here it is:

Arduino code :

int ledPin13 = 13;
int ledPin12 = 12;
int dato;

void setup() {
Serial.begin(9600);
pinMode(ledPin13, OUTPUT);
pinMode(ledPin12, OUTPUT);
}

void loop() {

if (Serial.available() > 0) {

dato = Serial.read();

if (dato == '1') {
digitalWrite(ledPin13, HIGH);
}
if (dato == '2') {
digitalWrite(ledPin13, LOW);
}
}
}

------------------------------------------------------->

VB code :

Imports System.IO.Ports
Imports System.Threading

Public Class Form1
Dim Mypin13 As Boolean = True

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
SerialPort1.Close()
SerialPort1.PortName = "com17" 'Chage to your 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_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
SerialPort1.Open()
SerialPort1.Write("1")
SerialPort1.Close()
End Sub

Private Sub Button1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp
SerialPort1.Open()
SerialPort1.Write("2")
SerialPort1.Close()
End Sub
End Class

...simple isnt itยฟ ... trying is the key
thank you again Paul and all of this forum