Bonjour,
je cherche à piloter 4 servomoteurS depuis un win form avec 4 track bar
j'ai donc l'architecture suivante pc---usb---arduino----4 servomoteurs

Pour piloter un servomoteur pas de problème voila le code 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
17
18
19
20
21
22
23
 
#include <Servo.h>
 
Servo articulationa;
 
int val=0;
 
 
void setup() {
 Serial.begin(9600);
 articulationa.attach(3);
 
 }
 
void loop() {
 
 
      }
 
void serialEvent() {
   val=Serial.parseInt();
    articulationa.write(val);
      }

et le code c# (à l'écran deux boutons (connecté) et (déconnecté) permettant d'ouvrir le port de communication , une checkbox permettant de sélectionner la trackbar et la trackbar permettant de déplacer le servomoteur)

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
 
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)
        { }
 
        }
Le problème c'est que je ne sais pas comment faire pour ensuite transformer ce programme de manière à piloter deux servomoteurs :
le problème comment sélectionner le servomoteur à piloter?