Imports System.IO Imports System.IO.Ports Public Class Form1 Dim drag As Boolean Dim mousex As Integer Dim mousey As Integer Dim bibi As Byte Dim coco As String = "" Dim Moo As Byte = 0 Dim Tb(7) As Byte Dim AfficheDigits As Byte = 1 Dim AfficheLeds As Byte = 0 Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load CalculVersion() For i = 0 To 7 Led(i).Tag = 0 Next Dim Troc As PictureBox For Each Troc In Led AddHandler Troc.MouseEnter, AddressOf Led_Hover Next SerialPort1.Close() SerialPort1.PortName = "COM5" 'My.Settings.PortCom SerialPort1.Encoding = System.Text.Encoding.Default PortOpen() Label9.Text = "Arduino port is " & SerialPort1.PortName End Sub Private Sub Led_Hover(sender As Object, e As EventArgs) Dim H As Byte = Mid(sender.name.ToString, 2) ClickLed(H) End Sub Private Sub PortOpen() Try SerialPort1.Open() Catch ex As Exception MsgBox("Check the connection with Arduino card or change the COM port.", MsgBoxStyle.Exclamation, "Problem") End End Try End Sub Private Sub ClickLed(ByVal H As Byte) If Led(H).Tag = 0 Then Led(H).Image = My.Resources.led1 Led(H).Tag = 1 Else Led(H).Image = My.Resources.led2 Led(H).Tag = 0 End If Dim gege As String = Led(0).Tag & Led(1).Tag & Led(2).Tag & Led(3).Tag & Led(4).Tag & Led(5).Tag & Led(6).Tag & Led(7).Tag bibi = Convert.ToInt32(gege, 2) Label21.Text = gege Label20.Text = Hex(bibi).ToString().PadLeft(2, "0") Label17.Text = bibi For i = 0 To 7 Tb(i) = 255 * Led(i).Tag Next SerialPort1.WriteLine("1," & bibi) End Sub Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing End End Sub Private Sub BarreHaut_MouseDown(sender As Object, e As MouseEventArgs) Handles BarreHaut.MouseDown drag = True mousex = Cursor.Position.X - Me.Left mousey = Cursor.Position.Y - Me.Top End Sub Private Sub BarreHaut_MouseMove(sender As Object, e As MouseEventArgs) Handles BarreHaut.MouseMove If drag Then Me.Top = Cursor.Position.Y - mousey Me.Left = Cursor.Position.X - mousex End If End Sub Private Sub BarreHaut_MouseUp(sender As Object, e As MouseEventArgs) Handles BarreHaut.MouseUp drag = False End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Application.Exit() End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Me.WindowState = FormWindowState.Minimized End Sub End Class