Bonjour tous le monde

Je souhaite trouver une solution pour connecter windows avec l'arduino mais je n'y arrive pas.

J'ai essayé de créer un programme VS studio avec une connexion automatique comme expliqué ICI sans succès
Le Programme VS:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
 
Imports System.IO.Ports
 
 
Public Class Form1
 
    Dim ArduinoConnected As Boolean
 
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TimerConnect.Enabled = False
        ArduinoConnected = False
        Autoconnect()
    End Sub
 
    Private Sub BtnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
        If ArduinoConnected Then
            SerialPort1.Close()
            btnConnect.Text = "Connect"
        Else
            Autoconnect()
        End If
    End Sub
 
    Private Sub Autoconnect()
        For Each sp As String In My.Computer.Ports.SerialPortNames
            Try
                SerialPort1.PortName = sp
                SerialPort1.BaudRate = 9600
                SerialPort1.DataBits = 8
                SerialPort1.Parity = Parity.None
                SerialPort1.StopBits = StopBits.One
                SerialPort1.Handshake = Handshake.None
                SerialPort1.Encoding = System.Text.Encoding.Default
                SerialPort1.Open()
                SerialPort1.Write("3/")
                TimerConnect.Interval = 500
                TimerConnect.Start()
                While TimerConnect.Enabled And ArduinoConnected = False
                    Application.DoEvents()
                End While
                If ArduinoConnected Then
                    btnConnect.Text = "Disconnect"
                    Exit For
                End If
                SerialPort1.Close()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        Next
        If ArduinoConnected = False Then
            MsgBox("Arduino failed to connect. Please check that it is plugged in.")
        End If
    End Sub
 
 
    Public Sub SerialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs)
        Dim str As String = SerialPort1.ReadExisting()
        If str.Contains("Arduino") Then
            ArduinoConnected = True
            lstConsole.Items.Add("Arduino Connected")
 
        End If
    End Sub
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 
        Shell("shutdown -s -t 100")
 
    End Sub
 
End Class
Programme Arduino
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
void setup()
{
Serial.begin(9600);
}
 
void loop()
{
 
if (Serial.read() == "3/")
 
{
Serial.print("Arduino");
}
 
}
Le "Shell("shutdown -s -t 100")" pour le test avec un buton (fonctionnel).

Si l'arduino n'est pas connecté il m'affiche bien l'erreur ""Arduino failed to connect..." mais si l'arduino est connecté le programme reste figé et sans erreur sans affiche le Form.
Avez-vous des idées ?


Merci d'avance pour votre aide