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
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports;
namespace commandearticulaire
{
public partial class Form1 : Form
{
SerialPort port = new SerialPort();
public string data;
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e) { }
private void trackBar1_Scroll(object sender, EventArgs e)
{
if (port.IsOpen & checkBox1.Checked)
{
port.WriteLine(trackBar1.Value.ToString());
valarti2.Text = "angleepaule2=" + trackBar1.Value.ToString(); } }
private void Form3_FormClosing(object sender, FormClosingEventArgs e)
{ {
if (port.IsOpen) port.Close();
} }
private void Form1_Load(object sender, EventArgs e)
{ }
private void connecté_Click(object sender, EventArgs e)
{ port.PortName = "COM4";
port.BaudRate = 9600;
port.Open();
if (port.IsOpen)
{
connecté.Enabled = false;
déconnecté.Enabled = true; } }
private void déconnecté_Click(object sender, EventArgs e)
{
port.Close();
if (!port.IsOpen)
{ connecté.Enabled = true;
déconnecté.Enabled = false; } }
private void checkBox1_Click(object sender, EventArgs e)
{ }
} |
Partager