예제 #1
0
        private void ConnectArduino()
        {
            try
            {
                string Port = comPortList.GetItemText(comPortList.SelectedItem);
                ArduinoPort.PortName = Port;
                ArduinoPort.Open();
                connected = true;

                ConnectBtn.BackColor = Color.Crimson;
                ConnectBtn.Text      = "DISCONNECT";
                StateLabel.Text      = "CONNECTED";
                StateLabel.ForeColor = Color.LimeGreen;
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
 static bool check_connection()
 {
     if (!ArduinoPort.IsOpen)
     {
         try
         {
             ArduinoPort.Open();
             ArduinoPort.WriteLine("T");
             ArduinoPort.Close();
         }
         catch
         {
             MessageBox.Show("There was an error. Please make sure that the correct port was selected, and that the device is plugged in.");
             return(false);
         }
         return(true);
     }
     else
     {
         return(true);
     }
 }
예제 #3
0
 public ArduinoForm()
 {
     InitializeComponent();
     ArduinoPort.Open();
 }