Connexion
S'inscrire
Actualités
Quoi de neuf
Activités générales
Auteurs
Forums
Nouveaux messages
Rechercher un forum
Quoi de neuf
Nouveaux messages
Nouveaux messages de profil
Activités générales
Membres
Membres inscrits
Visiteurs actuels
Nouveaux messages de profil
Rechercher dans les messages des profils
Teams
Créé ton équipe
Quoi de neuf ?
Nouveaux messages
Rechercher un forum
Menu
Connexion
S'inscrire
Install the app
Install
Forums
Forums généraux
Informatique
Développement
Questions, aides et recherches
Résolus
visual basic ajouter un voyant
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Vous utilisez un navigateur non à jour ou ancien. Il ne peut pas afficher ce site ou d'autres sites correctement.
Vous devez le mettre à jour ou utiliser un
navigateur alternatif
.
Répondre à la discussion
Message
<blockquote data-quote="TitoGame" data-source="post: 6944203" data-attributes="member: 219659"><p>bon du coup ça pique un peu les yeux mais en mettant les main dans le "caca" tout fonctionne exactement comme je voulais, Merci pour votre aide en tout cas <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite355" alt=":)" title=":) :)" loading="lazy" data-shortname=":)" /></p><p>voici le code:</p><p>[CODE]</p><p>Public Class Form1</p><p></p><p> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load</p><p> Text1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))</p><p> Text1.BackColor = Color.Red</p><p> Text1.ForeColor = Color.White</p><p> Text1.TextAlign = HorizontalAlignment.Center</p><p> Text1.Text = "Port Fermé"</p><p> SerialPort1.Close()</p><p> SerialPort2.Close()</p><p></p><p> End Sub</p><p></p><p> Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Connect.Click</p><p> Text1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))</p><p> With SerialPort1</p><p> If .PortName = "COM9" Then</p><p> Text1.TextAlign = HorizontalAlignment.Center</p><p> Text1.ForeColor = Color.White</p><p> Text1.Text = "Port Ouvert"</p><p> Text1.BackColor = Color.Green</p><p> Else</p><p> Text1.BackColor = Color.Red</p><p> End If</p><p></p><p></p><p></p><p> End With</p><p> With SerialPort1</p><p> .PortName = "COM9"</p><p> .BaudRate = 9600</p><p> .DataBits = 8</p><p> .Parity = IO.Ports.Parity.None</p><p> .StopBits = IO.Ports.StopBits.One</p><p> .Handshake = IO.Ports.Handshake.None</p><p> End With</p><p></p><p> Try</p><p> SerialPort1.Open()</p><p> Catch ex As Exception</p><p> MessageBox.Show(ex.ToString)</p><p> End Try</p><p> End Sub</p><p></p><p> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btOn.Click</p><p> SerialPort1.Write("1")</p><p> End Sub</p><p></p><p> Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btOff.Click</p><p> SerialPort1.Write("0")</p><p> End Sub</p><p></p><p> Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Disconnect.Click</p><p> Text1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))</p><p> With SerialPort2</p><p> If .PortName = "COM9" Then</p><p> Text1.TextAlign = HorizontalAlignment.Center</p><p> Text1.ForeColor = Color.White</p><p> Text1.Text = "Port Fermé"</p><p> Text1.BackColor = Color.Red</p><p> SerialPort2.Close()</p><p></p><p> End If</p><p> End With</p><p></p><p> With SerialPort2</p><p> .PortName = "COM9"</p><p> .BaudRate = 9600</p><p> .DataBits = 8</p><p> .Parity = IO.Ports.Parity.None</p><p> .StopBits = IO.Ports.StopBits.One</p><p> .Handshake = IO.Ports.Handshake.None</p><p> End With</p><p></p><p> Try</p><p> SerialPort1.Close()</p><p> Catch ex As Exception</p><p> MessageBox.Show(ex.ToString)</p><p> End Try</p><p></p><p> End Sub</p><p></p><p></p><p> Private Sub Text1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Text1.TextChanged</p><p></p><p> End Sub</p><p></p><p>End Class</p><p>[/CODE]</p><p></p><p>Pour les curieux voici le code coté arduino, ça suffit pour allumer est éteindre la LED depuis l'interface vb:</p><p>[CODE]</p><p>int Led = 2;</p><p></p><p></p><p>void setup() {</p><p> Serial.begin(9600);</p><p> pinMode(Led,OUTPUT);</p><p></p><p>}</p><p></p><p>void loop() {</p><p></p><p> if (Serial.available())</p><p>{</p><p> int led = Serial.read() - 48;</p><p> Serial.println(led);</p><p> if (led == 1)</p><p> digitalWrite(Led,HIGH);</p><p> </p><p> if (led == 0)</p><p> digitalWrite(Led,LOW);</p><p>}</p><p></p><p> </p><p></p><p>}</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="TitoGame, post: 6944203, member: 219659"] bon du coup ça pique un peu les yeux mais en mettant les main dans le "caca" tout fonctionne exactement comme je voulais, Merci pour votre aide en tout cas :) voici le code: [CODE] Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Text1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Text1.BackColor = Color.Red Text1.ForeColor = Color.White Text1.TextAlign = HorizontalAlignment.Center Text1.Text = "Port Fermé" SerialPort1.Close() SerialPort2.Close() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Connect.Click Text1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) With SerialPort1 If .PortName = "COM9" Then Text1.TextAlign = HorizontalAlignment.Center Text1.ForeColor = Color.White Text1.Text = "Port Ouvert" Text1.BackColor = Color.Green Else Text1.BackColor = Color.Red End If End With With SerialPort1 .PortName = "COM9" .BaudRate = 9600 .DataBits = 8 .Parity = IO.Ports.Parity.None .StopBits = IO.Ports.StopBits.One .Handshake = IO.Ports.Handshake.None End With Try SerialPort1.Open() Catch ex As Exception MessageBox.Show(ex.ToString) End Try End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btOn.Click SerialPort1.Write("1") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btOff.Click SerialPort1.Write("0") End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Disconnect.Click Text1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) With SerialPort2 If .PortName = "COM9" Then Text1.TextAlign = HorizontalAlignment.Center Text1.ForeColor = Color.White Text1.Text = "Port Fermé" Text1.BackColor = Color.Red SerialPort2.Close() End If End With With SerialPort2 .PortName = "COM9" .BaudRate = 9600 .DataBits = 8 .Parity = IO.Ports.Parity.None .StopBits = IO.Ports.StopBits.One .Handshake = IO.Ports.Handshake.None End With Try SerialPort1.Close() Catch ex As Exception MessageBox.Show(ex.ToString) End Try End Sub Private Sub Text1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Text1.TextChanged End Sub End Class [/CODE] Pour les curieux voici le code coté arduino, ça suffit pour allumer est éteindre la LED depuis l'interface vb: [CODE] int Led = 2; void setup() { Serial.begin(9600); pinMode(Led,OUTPUT); } void loop() { if (Serial.available()) { int led = Serial.read() - 48; Serial.println(led); if (led == 1) digitalWrite(Led,HIGH); if (led == 0) digitalWrite(Led,LOW); } } [/CODE] [/QUOTE]
Insérer les citations…
Vérification
Publier la réponse
Forums
Forums généraux
Informatique
Développement
Questions, aides et recherches
Résolus
visual basic ajouter un voyant
Ce site utilise des cookies. En continuant à utiliser ce site, vous acceptez l'utilisation des cookies.
Acceptez
En savoir plus.…
Haut