Pilotage de plusieurs moteurs pas à pas combinés à des boutons poussoir et des potentiomètres sur arduino méga

Bonjour
Je dispose du montage et du programme suivant:

#include "AccelStepper.h"
#include "MTcheckButton.h"
#include "MTstepStepper.h"

const byte pinBoutonGouteAGouteVert = 3;
const byte pinBoutonGouteAGouteRouge = 4;
const byte pinBoutonMiseEnMarche = 8;
const byte pinBoutonMarcheRouge = 9;
const byte pinBoutonMarcheVert = 10;
const byte pinBoutonArretDUrgence = 11;

const byte boutonPinAffichage = 12;

int route1 = 0;
int route2 = 0;

const byte pinPotIngredient1 = A1;//ok
const byte pinPotIngredient2 = A2;//ok

const int minPotIngredient1 = 0;
const int maxPotIngredient1 = 1023;

const int minPotIngredient2 = 0;
const int maxPotIngredient2 = 1023;

const int boutonPinEtatOn = LOW;     // Etat lu du bouton quand pressé (LOW pour PULL_UP)

const byte dirMoteurVert = 2; 
const byte dirMoteurRouge = 5;       

const int StepMoteurVert = 7;
const int StepMoteurRouge = 6;


AccelStepper mpapVert(1, StepMoteurVert, dirMoteurVert);    
AccelStepper mpapRouge(1, StepMoteurRouge, dirMoteurRouge); 



int mpapNombreDePasAtourner = 200;

int ratio(int nb1, int nb2){
  if ((nb1 == 0) && (nb2 == 0)) return 0;
  return (100.0 * nb1) / (nb1 + nb2);
}
  void marcheMoteurVert(void){
    mpapVert.move(CONTINUE);
    mpapRouge.move(CONTINUE);
  }
  void marcheMoteurRouge(void){
    mpapVert.move(-CONTINUE);
    mpapRouge.move(-CONTINUE);
  }
    void arretMoteurVert(void){
    mpapVert.stop();
    mpapRouge.stop();
  }
  void arretMoteurRouge(void){
    mpapVert.stop();
    mpapRouge.stop();
  }

MTcheckButton BoutonMarcheVert(pinBoutonMarcheVert, marcheMoteurVert, arretMoteurVert);
MTcheckButton BoutonMarcheRouge(pinBoutonMarcheRouge, marcheMoteurRouge, arretMoteurRouge);

void setup()
{
  //pin d'affichage
  pinMode(boutonPinAffichage, INPUT_PULLUP);
  
  mpapVert.setMaxSpeed(1000);
  mpapVert.setAcceleration(1000);
  mpapRouge.setMaxSpeed(1000);
  mpapRouge.setAcceleration(1000);
  
  pinMode(pinBoutonGouteAGouteVert, INPUT_PULLUP);
  pinMode(pinBoutonGouteAGouteRouge, INPUT_PULLUP);
  pinMode(pinBoutonMiseEnMarche, INPUT_PULLUP);
  pinMode(pinBoutonMarcheRouge, INPUT_PULLUP);
  pinMode(pinBoutonMarcheVert, INPUT_PULLUP);
  pinMode(pinBoutonArretDUrgence, INPUT_PULLUP);

  //                    DIR    STEP  ENA
  mpapVert.setPinsInverted(false, false, true);
  mpapVert.enableOutputs();     // Activer les signaux du MPAP
  mpapRouge.setPinsInverted(false, false, true);
  mpapRouge.enableOutputs();     // Activer les signaux du MPAP

  Serial.begin(115200);
}

void loop(){
  int Ingredient1 = constrain(map(analogRead(pinPotIngredient1), minPotIngredient1, maxPotIngredient1, 0, 100), 0, 100);
  int Ingredient2 = constrain(map(analogRead(pinPotIngredient2), minPotIngredient2, maxPotIngredient2, 0, 100), 0, 100);
  int Ratio1 = ratio(Ingredient1, Ingredient2);
  int Ratio2 = ratio(Ingredient2, Ingredient1);
 
  //Bouton de mise en marche des réglages
  boolean etatBouton3=digitalRead(pinBoutonMiseEnMarche);
  if(etatBouton3 == boutonPinEtatOn){
    route1 = mpapNombreDePasAtourner * Ratio1;
    route2 = mpapNombreDePasAtourner * Ratio2;
    
    mpapVert.move(route1);
    mpapVert.run();
    mpapRouge.move(route2);
    mpapRouge.run();
  }
  //Bouton d'arrêt d'urgence
  boolean etatBouton4=digitalRead(pinBoutonArretDUrgence);//variable booléenne du bouton d'arrêt d'urgence
  if(etatBouton4 == boutonPinEtatOn){
    mpapVert.stop();
    mpapRouge.stop();
  }
  boolean etatBouton=digitalRead(pinBoutonGouteAGouteVert);
  if (etatBouton == boutonPinEtatOn)
  {
    mpapVert.move(mpapNombreDePasAtourner);
  }
  mpapVert.run();
  
  boolean etatBouton2=digitalRead(pinBoutonGouteAGouteRouge);
  if (etatBouton2 == boutonPinEtatOn)
  {
    mpapRouge.move(mpapNombreDePasAtourner);
    
  }
  mpapRouge.run();
  //Bouton d'affichage
  boolean etatBoutonAffichage=digitalRead(boutonPinAffichage);
  if (etatBoutonAffichage == boutonPinEtatOn){
    Serial.print("Ingredient1: "); Serial.print(Ratio1);  Serial.print("%\t");
    Serial.print("Ingredient2: "); Serial.print(Ratio2); Serial.println("%");
    delay(700);
  }
}

A chaque moteur pas à pas, est dédié un bouton qui permet de les faire tourner d'un certain nombre de pas lorsqu'on l'appuie une fois et les faire tourner en continue quand on reste appuyer dessus. Il y a également deux autres boutons (pas tout à fait au point) dont l'un qui permet de faire tourner les deux moteurs en même temps dans un sens lorsqu'on appuie une première fois dessus et qui les arrête lorsqu'on appuie une deuxième fois dessus. L'autre bouton fait la même chose mais fait tourner les deux moteurs en même temps dans le sens inverse. Il y a ensuite un quatrième bouton qui permet d'afficher les ratios de deux potentiomètres dans le moniteur, un cinquième qui sert à faire tourner les moteurs en même temps d'un nombre de pas par rapport aux ratios dans le moniteur série et un sixième qui sert de bouton d'arrêt d'urgence pour arrêter les moteurs.

Ce système fonctionne plutôt bien mais j'aimerai l'élargir avec une arduino méga, et 12 moteurs pas à pas dont 5 seraient dédiés à faire tomber des gouttes de couleurs en faisant tourner une pompe doseuse et 7 qui feraient la même chose mais avec des ingrédients liquides.


Afin de vous épargner la compléxité du schéma réel je n'ai représenter sur le schéma ci-dessus que deux moteurs pas à pas avec trois potentiomètres. En réalité sur la breadbord comprenant les potentiomètres il y en a 14, dont 5 destiné à régler les ratios des couleurs, 7 à régler celui des ingrédients, 1 à la quantité de gouttes de couleurs entre 0 et 100 et 1 dernier à régler la quantité total d'ingrédient entre 0 et 1000 ml. Sur la breadbord comprenant les drivers et les boutons faisant tourner d'un certain nombre de pas (ou en continue lorsque l'on reste appuyé dessus), se trouve en réalité 5 drivers, condensateurs et boutons cote à cote. Et encore sur la breadbord tout à droite du schéma se trouve 4 drivers, condensateurs et boutons. (Je n'ai pour le moment, pas encore assez de drivers pour placer les moteurs restant mais cela devrait normalement fonctionner). Enfin le reste des boutons du premier montage sont également présents.

#include "AccelStepper.h"
#include "MTcheckButton.h"
#include "MTstepStepper.h"


const byte boutonMTcheck1 = 50;
const byte boutonMTcheck2 = 49;

const byte boutonNemaIng1 = 32;
const byte boutonNemaIng2 = 34;
const byte boutonNemaIng3 = 33;
const byte boutonNemaIng4 = 52;
const byte boutonNemaIng5 = 53;
const byte boutonNemaIng6 = 3;
const byte boutonNemaIng7 = 4;

const byte boutonNemaRouge = 35;
const byte boutonNemaBleu = 36;
const byte boutonNemaJaune = 38;
const byte boutonNemaViolet = 51;
const byte boutonNemaGris = 29;

const byte boutonPinAffichage = 12;

const byte boutonMiseEnMarche = 8;

const byte boutonArretDUrgence = 18;

int routeRouge = 0;
int routeBleu = 0;
int routeJaune = 0;
int routeViolet = 0;
int routeGris = 0;
int routeIngredient1 = 0;
int routeIngredient2 = 0;
int routeIngredient3 = 0;
int routeIngredient4 = 0;
int routeIngredient5 = 0;
int routeIngredient6 = 0;
int routeIngredient7 = 0;


const byte pinPotQuantiteCouleur = A0;
const byte pinPotQuantiteIngredient = A1;

const byte pinPotRouge = A2;
const byte pinPotBleu = A3;
const byte pinPotJaune = A4;
const byte pinPotViolet = A5;
const byte pinPotGris = A6;

const byte pinPotIngredient1 = A7;
const byte pinPotIngredient2 = A8;
const byte pinPotIngredient3 = A9;
const byte pinPotIngredient4 = A10;
const byte pinPotIngredient5 = A11;
const byte pinPotIngredient6 = A12;
const byte pinPotIngredient7 = A13;

const int minPotQuantiteCouleur = 0;
const int maxPotQuantiteCouleur = 1023;

const int minPotQuantiteIngredient = 0;
const int maxPotQuantiteIngredient = 1023;

const int minPotRouge = 0;
const int maxPotRouge = 1023;

const int minPotBleu = 0;
const int maxPotBleu = 1023;

const int minPotJaune = 0;
const int maxPotJaune = 1023;

const int minPotViolet = 0;
const int maxPotViolet = 1023;

const int minPotGris = 0;
const int maxPotGris= 1023;

const int minPotIngredient1 = 0;
const int maxPotIngredient1 = 1023;

const int minPotIngredient2 = 0;
const int maxPotIngredient2 = 1023;

const int minPotIngredient3 = 0;
const int maxPotIngredient3 = 1023;

const int minPotIngredient4 = 0;
const int maxPotIngredient4 = 1023;

const int minPotIngredient5 = 0;
const int maxPotIngredient5 = 1023;

const int minPotIngredient6 = 0;
const int maxPotIngredient6 = 1023;

const int minPotIngredient7 = 0;
const int maxPotIngredient7 = 1023;

const int boutonPinEtatOn = LOW;     // Etat lu du bouton quand pressé (LOW pour PULL_UP)

const byte mpapDirPin = 24;     // Pour driver MPAP pin pas
const byte mpapStepPin = 25;     // Pour driver MPAP pin direction

const byte mpapDirPin2 = 26;     // Pour driver MPAP pin pas
const byte mpapStepPin2 = 27;     // Pour driver MPAP pin direction

const byte mpapDirPin3 = 30;     // Pour driver MPAP pin pas
const byte mpapStepPin3 = 31;     // Pour driver MPAP pin direction

const byte mpapDirPin4 = 28;     // Pour driver MPAP pin pas
const byte mpapStepPin4 = 22;     // Pour driver MPAP pin direction

const byte mpapDirPin5 = 0;     // Pour driver MPAP pin pas
const byte mpapStepPin5 = 1;     // Pour driver MPAP pin direction

const byte mpapDirPin6 = 5;     // Pour driver MPAP pin pas
const byte mpapStepPin6 = 6;     // Pour driver MPAP pin direction

const byte mpapDirPin7 = 2;     // Pour driver MPAP pin pas
const byte mpapStepPin7 = 7;     // Pour driver MPAP pin direction

const byte mpapDirPinRouge = 15;     // Pour driver MPAP pin pas
const byte mpapStepPinRouge = 14;     // Pour driver MPAP pin direction

const byte mpapDirPinBleu = 17;
const byte mpapStepPinBleu= 16;

const byte mpapDirPinJaune = 19;
const byte mpapStepPinJaune = 18;

const byte mpapDirPinViolet = 21;
const byte mpapStepPinViolet = 20;

const byte mpapDirPinGris = 39;
const byte mpapStepPinGris = 40;

AccelStepper MPAP1(1, mpapStepPin, mpapDirPin);     // 1 pour A4988
AccelStepper MPAP2(1, mpapStepPin2, mpapDirPin2);
AccelStepper MPAP3(1, mpapStepPin3, mpapDirPin3);
AccelStepper MPAP4(1, mpapStepPin4, mpapDirPin4);
AccelStepper MPAP5(1, mpapStepPin5, mpapDirPin5);
AccelStepper MPAP6(1, mpapStepPin6, mpapDirPin6);
AccelStepper MPAP7(1, mpapStepPin7, mpapDirPin7);

AccelStepper mpapRouge(1, mpapStepPinRouge, mpapDirPinRouge);
AccelStepper mpapBleu(1, mpapStepPinBleu, mpapDirPinBleu);
AccelStepper mpapJaune(1, mpapStepPinJaune, mpapDirPinJaune);
AccelStepper mpapViolet(1, mpapStepPinViolet, mpapDirPinViolet);
AccelStepper mpapGris(1, mpapStepPinGris, mpapDirPinGris);

int mpapNombreDePasAtourner = 200;

int ratio2(int nb3, int nb4,int nb5, int nb6, int nb7) {
  if ((nb3 == 0) && (nb4 == 0) && (nb5 == 0) && (nb6 == 0) && (nb7 == 0)) return 0;
  return (100.0 * nb3) / (nb3 + nb4 + nb5 + nb6 + nb7);
}

int ratio3(int nb8, int nb9, int nb10, int nb11, int nb12, int nb13, int nb14) {
  if ((nb8 == 0) && (nb9 == 0)&& (nb10 == 0) && (nb11 == 0) && (nb12 == 0) && (nb13 == 0) && (nb14 == 0)) return 0;
  return (100.0 * nb8) / (nb8 + nb9 + nb10 + nb11 + nb12 + nb13 + nb14);
}
  void marcheMpap1(void){
    //mpap1.move(CONTINUE);
    //mpap2.move(CONTINUE);

    MPAP1.move(CONTINUE);
    MPAP2.move(CONTINUE);
    MPAP3.move(CONTINUE);
    MPAP4.move(CONTINUE);
    MPAP5.move(CONTINUE);
    MPAP6.move(CONTINUE);
    MPAP7.move(CONTINUE);

    mpapRouge.move(CONTINUE);
    mpapBleu.move(CONTINUE);
    mpapJaune.move(CONTINUE);;
    mpapViolet.move(CONTINUE);
    mpapGris.move(CONTINUE);
  }
  void marcheMpap2(void){
    
    MPAP1.move(-CONTINUE);
    MPAP2.move(-CONTINUE);
    MPAP3.move(-CONTINUE);
    MPAP4.move(-CONTINUE);
    MPAP5.move(-CONTINUE);
    MPAP6.move(-CONTINUE);
    MPAP7.move(-CONTINUE);

    mpapRouge.move(-CONTINUE);
    mpapBleu.move(-CONTINUE);
    mpapJaune.move(-CONTINUE);;
    mpapViolet.move(-CONTINUE);
    mpapGris.move(-CONTINUE);
  }
    void arretMpap1(void){
    MPAP1.stop();
    MPAP2.stop();
    MPAP3.stop();
    MPAP4.stop();
    MPAP5.stop();
    MPAP6.stop();
    MPAP7.stop();

    mpapRouge.stop();
    mpapBleu.stop();
    mpapJaune.stop();
    mpapViolet.stop();
    mpapGris.stop();
  }
  void arretMpap2(void){
    MPAP1.stop();
    MPAP2.stop();
    MPAP3.stop();
    MPAP4.stop();
    MPAP5.stop();
    MPAP6.stop();
    MPAP7.stop();

    mpapRouge.stop();
    mpapBleu.stop();
    mpapJaune.stop();
    mpapViolet.stop();
    mpapGris.stop();
  }

MTcheckButton BoutonMarche(boutonMTcheck1, marcheMpap1, arretMpap1);
MTcheckButton BoutonArret(boutonMTcheck2, marcheMpap2, arretMpap2);

void setup()
{
  //pin d'affichage
  pinMode(boutonPinAffichage, INPUT_PULLUP);

  MPAP1.setMaxSpeed(400);
  MPAP1.setAcceleration(500);
  MPAP2.setMaxSpeed(400);
  MPAP2.setAcceleration(500);
  MPAP3.setMaxSpeed(400);
  MPAP3.setAcceleration(500);
  MPAP4.setMaxSpeed(400);
  MPAP4.setAcceleration(500);
  MPAP5.setMaxSpeed(400);
  MPAP5.setAcceleration(500);
  MPAP6.setMaxSpeed(400);
  MPAP6.setAcceleration(500);
  MPAP7.setMaxSpeed(400);
  MPAP7.setAcceleration(500);
  mpapRouge.setMaxSpeed(500);
  mpapRouge.setAcceleration(500);
  mpapBleu.setMaxSpeed(500);
  mpapBleu.setAcceleration(500);
  mpapJaune.setMaxSpeed(500);
  mpapJaune.setAcceleration(500);
  mpapViolet.setMaxSpeed(500);
  mpapViolet.setAcceleration(500);
  mpapGris.setMaxSpeed(500);
  mpapGris.setAcceleration(500);
  
  
  pinMode(boutonNemaIng1, INPUT_PULLUP);
  pinMode(boutonNemaIng2, INPUT_PULLUP);
  pinMode(boutonNemaIng3, INPUT_PULLUP);
  pinMode(boutonNemaIng4, INPUT_PULLUP);
  pinMode(boutonNemaIng5, INPUT_PULLUP);
  pinMode(boutonNemaIng6, INPUT_PULLUP);
  pinMode(boutonNemaIng7, INPUT_PULLUP);
  pinMode(boutonNemaRouge, INPUT_PULLUP);
  pinMode(boutonNemaBleu, INPUT_PULLUP);
  pinMode(boutonNemaJaune, INPUT_PULLUP);
  pinMode(boutonNemaViolet, INPUT_PULLUP);
  pinMode(boutonNemaGris, INPUT_PULLUP);
  

  //mpap1.setEnablePin(mpapEnaPin);
  //                    DIR    STEP  ENA
  MPAP1.setPinsInverted(false, false, true);
  MPAP1.enableOutputs();     // Activer les signaux du MPAP
  MPAP2.setPinsInverted(false, false, true);
  MPAP2.enableOutputs();     // Activer les signaux du MPAP
  MPAP3.setPinsInverted(false, false, true);
  MPAP3.enableOutputs();     // Activer les signaux du MPAP
  MPAP4.setPinsInverted(false, false, true);
  MPAP4.enableOutputs();     // Activer les signaux du MPAP
  MPAP5.setPinsInverted(false, false, true);
  MPAP5.enableOutputs();     // Activer les signaux du MPAP
  MPAP6.setPinsInverted(false, false, true);
  MPAP6.enableOutputs();     // Activer les signaux du MPAP
  MPAP7.setPinsInverted(false, false, true);
  MPAP7.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  // // // // // // // // // // // // // // // 
  Serial.begin(115200);
}

void loop(){
  int quantiteCouleur = constrain(map(analogRead(pinPotQuantiteCouleur),minPotQuantiteCouleur,maxPotQuantiteCouleur,0,100),0,100);
  int quantiteIngredient = constrain(map(analogRead(pinPotQuantiteIngredient),minPotQuantiteIngredient,maxPotQuantiteIngredient,0,1000),0,1000);
  int rouge = constrain(map(analogRead(pinPotRouge), minPotRouge, maxPotRouge,  0, quantiteCouleur), 0, 100);
  int bleu = constrain(map(analogRead(pinPotBleu), minPotBleu, maxPotBleu, 0, quantiteCouleur), 0, 100);
  int jaune = constrain(map(analogRead(pinPotJaune), minPotJaune, maxPotJaune,  0, quantiteCouleur), 0, 100);
  int violet = constrain(map(analogRead(pinPotViolet), minPotViolet, maxPotViolet,  0, quantiteCouleur), 0, 100);
  int gris = constrain(map(analogRead(pinPotGris), minPotGris, maxPotGris,  0, quantiteCouleur), 0, 100);
  int Ingredient1 = constrain(map(analogRead(pinPotIngredient1), minPotIngredient1, maxPotIngredient1, 0, quantiteIngredient), 0, 100);
  int Ingredient2 = constrain(map(analogRead(pinPotIngredient2), minPotIngredient2, maxPotIngredient2, 0, quantiteIngredient), 0, 100);
  int Ingredient3 = constrain(map(analogRead(pinPotIngredient3), minPotIngredient3, maxPotIngredient3, 0, quantiteIngredient), 0, 100);
  int Ingredient4 = constrain(map(analogRead(pinPotIngredient4), minPotIngredient4, maxPotIngredient4, 0, quantiteIngredient), 0, 100);
  int Ingredient5 = constrain(map(analogRead(pinPotIngredient5), minPotIngredient5, maxPotIngredient5, 0, quantiteIngredient), 0, 100);
  int Ingredient6 = constrain(map(analogRead(pinPotIngredient6), minPotIngredient6, maxPotIngredient6, 0, quantiteIngredient), 0, 100);
  int Ingredient7 = constrain(map(analogRead(pinPotIngredient7), minPotIngredient7, maxPotIngredient7, 0, quantiteIngredient), 0, 100);
  
  int RatioRouge = ratio2(rouge, bleu, jaune, violet, gris);
  int RatioBleu = ratio2(bleu, rouge, jaune, violet, gris);
  int RatioJaune = ratio2(jaune, bleu, rouge, violet, gris);
  int RatioViolet = ratio2(violet, bleu, jaune, rouge, gris);
  int RatioGris = ratio2(gris, bleu, jaune, violet, rouge);
  int RatioIngredient1 = ratio3(Ingredient1, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient7);
  int RatioIngredient2 = ratio3(Ingredient2, Ingredient1, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient7);
  int RatioIngredient3 = ratio3(Ingredient3, Ingredient2, Ingredient1, Ingredient4, Ingredient5, Ingredient6, Ingredient7);
  int RatioIngredient4 = ratio3(Ingredient4, Ingredient2, Ingredient3, Ingredient1, Ingredient5, Ingredient6, Ingredient7);
  int RatioIngredient5 = ratio3(Ingredient5, Ingredient2, Ingredient3, Ingredient4, Ingredient1, Ingredient6, Ingredient7);
  int RatioIngredient6 = ratio3(Ingredient6, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient1, Ingredient7);
  int RatioIngredient7 = ratio3(Ingredient7, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient1);
 
  //Bouton de mise en marche des réglages
  boolean etatBoutonMiseEnMarche=digitalRead(boutonMiseEnMarche);
  if(etatBoutonMiseEnMarche == boutonPinEtatOn){

    routeRouge = mpapNombreDePasAtourner * RatioRouge;
    routeBleu = mpapNombreDePasAtourner * RatioBleu;
    routeJaune = mpapNombreDePasAtourner * RatioJaune;
    routeViolet = mpapNombreDePasAtourner * RatioViolet;
    routeGris = mpapNombreDePasAtourner * RatioGris;
    routeIngredient1 = mpapNombreDePasAtourner * RatioIngredient1;
    routeIngredient2 = mpapNombreDePasAtourner * RatioIngredient2;
    routeIngredient3 = mpapNombreDePasAtourner * RatioIngredient3;
    routeIngredient4 = mpapNombreDePasAtourner * RatioIngredient4;
    routeIngredient5 = mpapNombreDePasAtourner * RatioIngredient5;
    routeIngredient6 = mpapNombreDePasAtourner * RatioIngredient6;
    routeIngredient7 = mpapNombreDePasAtourner * RatioIngredient7;

    MPAP1.move(routeIngredient1);
    MPAP1.run();
    MPAP2.move(routeIngredient2);
    MPAP2.run();
    MPAP3.move(routeIngredient3);
    MPAP3.run();
    MPAP4.move(routeIngredient4);
    MPAP4.run();
    MPAP5.move(routeIngredient5);
    MPAP5.run();
    MPAP6.move(routeIngredient6);
    MPAP6.run();
    MPAP7.move(routeIngredient7);
    MPAP7.run();
    mpapRouge.move(routeRouge);
    mpapRouge.run();
    mpapBleu.move(routeBleu);
    mpapBleu.run();
    mpapJaune.move(routeJaune);
    mpapJaune.run();
    mpapViolet.move(routeViolet);
    mpapViolet.run();
    mpapGris.move(routeGris);
    mpapGris.run();
  }
  //Bouton d'arrêt d'urgence
  boolean etatBoutonArretDUrgence=digitalRead(boutonArretDUrgence);//variable booléenne du bouton d'arrêt d'urgence
  if(etatBoutonArretDUrgence == boutonPinEtatOn){
    MPAP1.stop();
    MPAP2.stop();
    MPAP3.stop();
    MPAP4.stop();
    MPAP5.stop();
    MPAP6.stop();
    MPAP7.stop();
    mpapRouge.stop();
    mpapBleu.stop();
    mpapJaune.stop();
    mpapViolet.stop();
    mpapGris.stop();
  }
  
  boolean etatBouton=digitalRead(boutonNemaIng1);
  if (etatBouton == boutonPinEtatOn)
  {
    MPAP1.move(mpapNombreDePasAtourner);
  }
  MPAP1.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton2=digitalRead(boutonNemaIng2);
  if (etatBouton2 == boutonPinEtatOn)
  {
    MPAP2.move(mpapNombreDePasAtourner);
  }
  MPAP2.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton3 = digitalRead(boutonNemaIng3);
  if (etatBouton3 == boutonPinEtatOn)
  {
    MPAP3.move(mpapNombreDePasAtourner);
  }
  MPAP3.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton4 = digitalRead(boutonNemaIng4);
  if (etatBouton4 == boutonPinEtatOn)
  {
    MPAP4.move(mpapNombreDePasAtourner);
  }
  MPAP4.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton5 = digitalRead(boutonNemaIng5);
  if (etatBouton5 == boutonPinEtatOn)
  {
    MPAP5.move(mpapNombreDePasAtourner);
  }
  MPAP5.run();
  // // // // // // // // // // // // // // //
  boolean etatBouton6 = digitalRead(boutonNemaIng6);
  if (etatBouton6 == boutonPinEtatOn)
  {
    MPAP6.move(mpapNombreDePasAtourner);
  }
  MPAP6.run();
  // // // // // // // // // // // // // // //
  boolean etatBouton7 = digitalRead(boutonNemaIng7);
  if (etatBouton7 == boutonPinEtatOn)
  {
    MPAP7.move(mpapNombreDePasAtourner);
  }
  MPAP7.run();
  // // // // // // // // // // // // // // //
  // // // // // // // // // // // // // // //
  boolean etatBouton11 = digitalRead(boutonNemaRouge);
  if (etatBouton11 == boutonPinEtatOn){
    mpapRouge.move(mpapNombreDePasAtourner);
  } 
  mpapRouge.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton12 = digitalRead(boutonNemaBleu);
  if (etatBouton12 == boutonPinEtatOn){
    mpapBleu.move(mpapNombreDePasAtourner);
  } 
  mpapBleu.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton13 = digitalRead(boutonNemaJaune);
  if (etatBouton13 == boutonPinEtatOn){
    mpapJaune.move(-mpapNombreDePasAtourner);
  } 
  mpapJaune.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton14 = digitalRead(boutonNemaViolet);
  if (etatBouton14 == boutonPinEtatOn){
    mpapViolet.move(mpapNombreDePasAtourner);
  } 
  mpapViolet.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton15 = digitalRead(boutonNemaGris);
  if (etatBouton15 == boutonPinEtatOn){
    mpapGris.move(mpapNombreDePasAtourner);
  } 
  mpapGris.run();
  
  
  //Bouton d'affichage
  boolean etatBoutonAffichage=digitalRead(boutonPinAffichage);
  if (etatBoutonAffichage == boutonPinEtatOn){
    Serial.print("Qte couleur:"); Serial.print(quantiteCouleur);  Serial.print(" gouttes |");
    Serial.print("Qte ingredient:");  Serial.print(quantiteIngredient); Serial.print(" ml |");
    Serial.print("rouge:");  Serial.print(ratio2(rouge, bleu, jaune, violet, gris)); Serial.print("% |");
    Serial.print("bleu:");  Serial.print(ratio2(bleu, rouge, jaune, violet, gris)); Serial.print("% |");
    Serial.print("jaune:");  Serial.print(ratio2(jaune, bleu, rouge, violet, gris)); Serial.print("% |");
    Serial.print("violet:");  Serial.print(ratio2(violet, bleu, jaune, rouge, gris)); Serial.print("% |");
    Serial.print("gris:");  Serial.print(ratio2(gris, bleu, jaune, violet, rouge)); Serial.print("% |");
    //////////////////////////////////////////////////////////////////////////////////////
    Serial.print("Ing1:");  Serial.print(ratio3(Ingredient1, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient7)); Serial.print("% |");
    Serial.print("Ing2:");  Serial.print(ratio3(Ingredient2, Ingredient1, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient7)); Serial.print("% |");
    Serial.print("Ing3:");  Serial.print(ratio3(Ingredient3, Ingredient2, Ingredient1, Ingredient4, Ingredient5, Ingredient6, Ingredient7)); Serial.print("% |");
    Serial.print("Ing4:");  Serial.print(ratio3(Ingredient4, Ingredient2, Ingredient3, Ingredient1, Ingredient5, Ingredient6, Ingredient7)); Serial.print("% |");
    Serial.print("Ing5:");  Serial.print(ratio3(Ingredient5, Ingredient2, Ingredient3, Ingredient4, Ingredient1, Ingredient6, Ingredient7)); Serial.print("% |");
    Serial.print("Ing6:");  Serial.print(ratio3(Ingredient6, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient1, Ingredient7)); Serial.print("% |");
    Serial.print("Ing7:");  Serial.print(ratio3(Ingredient7, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient1)); Serial.println("%");
    delay(700);
    
  }
}

Le problème que j'ai est que lorsque je met le système sous tension de 12V via un adaptateur comme sur le schéma, tous les moteurs branchés se mettent à tourner seuls sans que l'on est appuyé sur les bouton sauf celui qui est dédié à l'ingrédient 5.
Comment pourrait-je remédier à ce problème ?

Cordialement

Déjà, si tu mets while(1); à la fin du setup() est-ce que les moteurs tournent?
Si oui, le problème est dans ton setup()
Si non, le problème est dans ton loop()

Que suis je censé placer entre les parenthèses et les accolades du while pour ce faire ?

Cordialement

Rien c'est tel que je l'ai écrit dans le message au-dessus. C'est juste une boucle infinie pour arrêter le déroulement du programme.

Pour qu'un moteur tourne avec accelStepper, il faut appeler régulièrement la fonction run() qui n'est présente que dans loop(). C'est donc dans loop() que peut (à priori) se trouver le problème.

Pour qu'un moteur tourne il faut en plus passer sur une instruction move() qui sont toutes soumises à un bouton. Il y en a peut être un (ou plusieurs) qui sont câblés sur la mauvaise broche. C'est pour cela que l'on conseille avec ce type de bouton d'utiliser les broches opposées et pas côte à côte.

Pour trouver la panne, on peut mettre un println chaque fois que l'on a un test de bouton de mise en marche. Par exemple remplacer:

  if(etatBoutonMiseEnMarche == boutonPinEtatOn){

    routeRouge = mpapNombreDePasAtourner * RatioRouge;

par:

  if(etatBoutonMiseEnMarche == boutonPinEtatOn){

    Serial.println("etatBoutonMiseEnMarche est LOW ");
    routeRouge = mpapNombreDePasAtourner * RatioRouge;

Le coupable devrait s'afficher. Il se peut qu'un inter soit incorrectement branché ou qu'il soit en court-circuit à l'intérieur.

ICI

je ne suis plus, ça sert à quoi que villeroi se décarcasse :grinning:

Je ne force personne à utiliser MTobjects. C'est d'ailleurs utilisé pour les bouton. C'est
#include "MTstepStepper.h"
qui est presque de trop, vu que les moteurs passent par accelStepper
Je sis presque parce que la constante CONTINUE est définie dans ce fichier par "le plus grand entier sur 32 bits. Qui a pour effet de faire tourner un MTstepStepper à l'infini et un AccelStepper pour 2 millions de pas. C'est pas l'infini, mais à 400 pas/s, cela fait tout de même 60 jours de rotation. On peut dire que cela fonctionne.

Pour l'instant accelStepper ou MTStepStepper c'est à peu près pareil. Mais je vois qu'il y a plusieurs fonctions run() par moteur dont certains mal placés. En fait si AccelStepper était une évidence, MTstepStepper n'existerait peut être pas. Mais si la fonction run() pose trop de problèmes, on verra.

Bonsoir
J'ai placé le while (1) dans le setup donc je confirmes que le problème vient du loop.
Peut-être devrait je préciser que j'ai élargi le code en me servant dans un premier temps d'un programme ne possédant que la bibliothèque accelstepper et fonctionnant bien:

#include "AccelStepper.h"     // https://www.pjrc.com/teensy/td_libs_AccelStepper.html

const byte boutonNemaIng1 = 32;
const byte boutonNemaIng2 = 34;
const byte boutonNemaIng3 = 33;
const byte boutonNemaIng4 = 52;
const byte boutonNemaIng5 = 53;
const byte boutonNemaIng6 = 3;
const byte boutonNemaIng7 = 4;

const byte boutonNemaRouge = 35;
const byte boutonNemaBleu = 36;
const byte boutonNemaJaune = 38;
const byte boutonNemaViolet = 51;
const byte boutonNemaGris = 29;

const int boutonPinEtatOn = LOW;     // Etat lu du bouton quand pressé (LOW pour PULL_UP)

const byte mpapDirPin = 24;     
const byte mpapStepPin = 25;     

const byte mpapDirPin2 = 26;    
const byte mpapStepPin2 = 27;     

const byte mpapDirPin3 = 30;     
const byte mpapStepPin3 = 31;    

const byte mpapDirPin4 = 28;    
const byte mpapStepPin4 = 22;    

const byte mpapDirPin5 = 0;    
const byte mpapStepPin5 = 1;   

const byte mpapDirPin6 = 5;     
const byte mpapStepPin6 = 6;     

const byte mpapDirPin7 = 2;     
const byte mpapStepPin7 = 7; 

const byte mpapDirPinRouge = 15;   
const byte mpapStepPinRouge = 14;    

const byte mpapDirPinBleu = 17;
const byte mpapStepPinBleu = 16;

const byte mpapDirPinJaune = 19;
const byte mpapStepPinJaune = 18;

const byte mpapDirPinViolet = 21;
const byte mpapStepPinViolet = 20;

const byte mpapDirPinGris = 39;
const byte mpapStepPinGris = 40;



AccelStepper MPAP1(1, mpapStepPin, mpapDirPin);     // 1 pour A4988
AccelStepper MPAP2(1, mpapStepPin2, mpapDirPin2);
AccelStepper MPAP3(1, mpapStepPin3, mpapDirPin3);
AccelStepper MPAP4(1, mpapStepPin4, mpapDirPin4);
AccelStepper MPAP5(1, mpapStepPin5, mpapDirPin5);
AccelStepper MPAP6(1, mpapStepPin6, mpapDirPin6);
AccelStepper MPAP7(1, mpapStepPin7, mpapDirPin7);

AccelStepper mpapRouge(1, mpapStepPinRouge, mpapDirPinRouge);
AccelStepper mpapBleu(1, mpapStepPinBleu, mpapDirPinBleu);
AccelStepper mpapJaune(1, mpapStepPinJaune, mpapDirPinJaune);
AccelStepper mpapViolet(1, mpapStepPinViolet, mpapDirPinViolet);
AccelStepper mpapGris(1, mpapStepPinGris, mpapDirPinGris); 

int mpapNombreDePasAtourner = 100;

void setup()
{
  MPAP1.setMaxSpeed(400);
  MPAP1.setAcceleration(500);
  
  pinMode(boutonNemaIng1, INPUT_PULLUP);

  //mpap1.setEnablePin(mpapEnaPin);
  //                    DIR    STEP  ENA
  MPAP1.setPinsInverted(false, false, true);
  MPAP1.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  MPAP2.setMaxSpeed(400);
  MPAP2.setAcceleration(500);

  pinMode(boutonNemaIng2, INPUT_PULLUP);

  MPAP2.setPinsInverted(false, false, true);
  MPAP2.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  MPAP3.setMaxSpeed(400);
  MPAP3.setAcceleration(500);

  pinMode(boutonNemaIng3, INPUT_PULLUP);

  MPAP3.setPinsInverted(false, false, true);
  MPAP3.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  MPAP4.setMaxSpeed(400);
  MPAP4.setAcceleration(500);

  pinMode(boutonNemaIng4, INPUT_PULLUP);

  MPAP4.setPinsInverted(false, false, true);
  MPAP4.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  MPAP5.setMaxSpeed(400);
  MPAP5.setAcceleration(500);

  pinMode(boutonNemaIng5, INPUT_PULLUP);

  MPAP5.setPinsInverted(false, false, true);
  MPAP5.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  MPAP6.setMaxSpeed(400);
  MPAP6.setAcceleration(500);

  pinMode(boutonNemaIng6, INPUT_PULLUP);

  MPAP6.setPinsInverted(false, false, true);
  MPAP6.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  MPAP7.setMaxSpeed(400);
  MPAP7.setAcceleration(500);

  pinMode(boutonNemaIng7, INPUT_PULLUP);

  MPAP7.setPinsInverted(false, false, true);
  MPAP7.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  // // // // // // // // // // // // // // // 
  mpapRouge.setMaxSpeed(500);
  mpapRouge.setAcceleration(500);

  pinMode(boutonNemaRouge, INPUT_PULLUP);
  // // // // // // // // // // // // // // //
  mpapBleu.setMaxSpeed(500);
  mpapBleu.setAcceleration(500);

  pinMode(boutonNemaBleu, INPUT_PULLUP);
  // // // // // // // // // // // // // // //
  mpapJaune.setMaxSpeed(500);
  mpapJaune.setAcceleration(500);

  pinMode(boutonNemaJaune, INPUT_PULLUP);
  // // // // // // // // // // // // // // //
  mpapViolet.setMaxSpeed(500);
  mpapViolet.setAcceleration(500);

  pinMode(boutonNemaViolet, INPUT_PULLUP);
  // // // // // // // // // // // // // // //
  mpapGris.setMaxSpeed(500);
  mpapGris.setAcceleration(500);

  pinMode(boutonNemaGris, INPUT_PULLUP);
}

void loop()
{
  boolean etatBouton=digitalRead(boutonNemaIng1);
  if (etatBouton == boutonPinEtatOn)
  {
    MPAP1.move(mpapNombreDePasAtourner);
  }
  MPAP1.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton2=digitalRead(boutonNemaIng2);
  if (etatBouton2 == boutonPinEtatOn)
  {
    MPAP2.move(mpapNombreDePasAtourner);
  }
  MPAP2.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton3 = digitalRead(boutonNemaIng3);
  if (etatBouton3 == boutonPinEtatOn)
  {
    MPAP3.move(mpapNombreDePasAtourner);
  }
  MPAP3.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton4 = digitalRead(boutonNemaIng4);
  if (etatBouton4 == boutonPinEtatOn)
  {
    MPAP4.move(mpapNombreDePasAtourner);
  }
  MPAP4.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton5 = digitalRead(boutonNemaIng5);
  if (etatBouton5 == boutonPinEtatOn)
  {
    MPAP5.move(mpapNombreDePasAtourner);
  }
  MPAP5.run();
  // // // // // // // // // // // // // // //
  boolean etatBouton6 = digitalRead(boutonNemaIng6);
  if (etatBouton6 == boutonPinEtatOn)
  {
    MPAP6.move(mpapNombreDePasAtourner);
  }
  MPAP6.run();
  // // // // // // // // // // // // // // //
  boolean etatBouton7 = digitalRead(boutonNemaIng7);
  if (etatBouton7 == boutonPinEtatOn)
  {
    MPAP7.move(mpapNombreDePasAtourner);
  }
  MPAP7.run();
  // // // // // // // // // // // // // // //
  // // // // // // // // // // // // // // //
  boolean etatBouton11 = digitalRead(boutonNemaRouge);
  if (etatBouton11 == boutonPinEtatOn){
    mpapRouge.move(mpapNombreDePasAtourner);
  } 
  mpapRouge.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton12 = digitalRead(boutonNemaBleu);
  if (etatBouton12 == boutonPinEtatOn){
    mpapBleu.move(mpapNombreDePasAtourner);
  } 
  mpapBleu.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton13 = digitalRead(boutonNemaJaune);
  if (etatBouton13 == boutonPinEtatOn){
    mpapJaune.move(-mpapNombreDePasAtourner);
  } 
  mpapJaune.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton14 = digitalRead(boutonNemaViolet);
  if (etatBouton14 == boutonPinEtatOn){
    mpapViolet.move(mpapNombreDePasAtourner);
  } 
  mpapViolet.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton15 = digitalRead(boutonNemaGris);
  if (etatBouton15 == boutonPinEtatOn){
    mpapGris.move(mpapNombreDePasAtourner);
  } 
  mpapGris.run();
}

J'ai remplacer:

if(etatBoutonMiseEnMarche == boutonPinEtatOn){

    routeRouge = mpapNombreDePasAtourner * RatioRouge;

par:

  if(etatBoutonMiseEnMarche == boutonPinEtatOn){

    Serial.println("etatBoutonMiseEnMarche est LOW ");
    routeRouge = mpapNombreDePasAtourner * RatioRouge;

Voici ce que le moniteur série m'a affiché alors que jusqu'à lors il ne m'affichait rien quand j'appuyais sur le bouton d'affichage:


Pareil pour le bouton d'arrêt d'urgence:

if(etatBoutonArretDUrgence == boutonPinEtatOn){
    Serial.println("etatBoutonMiseEnMarche est LOW ");

J'ai également effectué le remplacement pour les boutons d'ingrédient et le moniteur m'affiche également la même chose mais seulement quand j'appuie sur le bouton:

if (etatBouton4 == boutonPinEtatOn)
  {
    Serial.println("etatBoutonMiseEnMarche est LOW ");
    MPAP4.move(mpapNombreDePasAtourner);
  }

En revanche pour le bouton d'affichage, absolument rien ne s'affiche:
image

Pareil pour les boutons des moteurs de couleur et les boutons MTcheckButton:

if (etatBouton12 == boutonPinEtatOn){
    Serial.println("etatBoutonMiseEnMarche est LOW ");
    mpapBleu.move(mpapNombreDePasAtourner);
  }

image

Le problème viendrait-il de tous ces boutons qui refusent d'afficher de l'écriture dans le moniteur série ?

Cordialement

le bouton associé à boutonMiseEnMarche (broche 8) n'est pas en INPUT_PULLUP. Il est LOW à la mise sous tension et reste donc LOW sans le pullup. Il est donc considéré comme actif par le programme.

Solution: rajouter
pinMode(boutonMiseEnMarche, INPUT_PULLUP);
dans le setup

Note: MTbutton initialise le pullup par défaut. Ce n'est pas le cas des boutons ne passant pas par MTobjects.


Note: arretMpap1 et arretMpap1 font la même chose. On peut en supprimer un des deux et renommer l'autre en arretMpap. La déclatation des Boutons marche et arrêt devient alors:

MTcheckButton BoutonMarche(boutonMTcheck1, marcheMpap1, arretMpap);
MTcheckButton BoutonArret(boutonMTcheck2, marcheMpap2, arretMpap);

J'ai ajouté:

  pinMode(boutonMiseEnMarche, INPUT_PULLUP);
  pinMode(boutonArretDUrgence, INPUT_PULLUP);

ainsi que:

MTcheckButton BoutonMarche(boutonMTcheck1, marcheMpap1, arretMpap);
MTcheckButton BoutonArret(boutonMTcheck2, marcheMpap2, arretMpap);

et remplacé les broches 0 et 1 par 45 et 47 pour les dir et step du driver du moteur de l'ingrédient 5:

const byte mpapDirPin5 = 47;
const byte mpapStepPin5 = 45; 

Cette fois ci les moteurs ne tournent pas lorsqu'on les met sous tension, toutefois lorsqu'on appuie sur les boutons qui leur sont dédié, ils tournent en continue jusqu'à ce que l'on réappuie sur le bouton qui leur est dédié, et le moteurs 5 qui ne tournait pas, cette fois-ci tourne mais plus lentement que les autres. Quant aux boutons d'affichage, d'arrêt d'urgence et rotation en continuent, ils ne fonctionnent toujours pas. Je souhaiterais que ce système agisse comme celui avec une arduino uno plus haut mais en plus grand.
Voici le nouveau programme complet:

#include "AccelStepper.h"
#include "MTcheckButton.h"
#include "MTstepStepper.h"


const byte boutonMTcheck1 = 50;
const byte boutonMTcheck2 = 51;

const byte boutonNemaIng1 = 32;
const byte boutonNemaIng2 = 34;
const byte boutonNemaIng3 = 33;
const byte boutonNemaIng4 = 52;
const byte boutonNemaIng5 = 53;
const byte boutonNemaIng6 = 3;
const byte boutonNemaIng7 = 4;

const byte boutonNemaRouge = 35;
const byte boutonNemaBleu = 36;
const byte boutonNemaJaune = 38;
const byte boutonNemaViolet = 49;
const byte boutonNemaGris = 29;

const byte boutonPinAffichage = 12;

const byte boutonMiseEnMarche = 8;

const byte boutonArretDUrgence = 18;

int routeRouge = 0;
int routeBleu = 0;
int routeJaune = 0;
int routeViolet = 0;
int routeGris = 0;
int routeIngredient1 = 0;
int routeIngredient2 = 0;
int routeIngredient3 = 0;
int routeIngredient4 = 0;
int routeIngredient5 = 0;
int routeIngredient6 = 0;
int routeIngredient7 = 0;


const byte pinPotQuantiteCouleur = A0;
const byte pinPotQuantiteIngredient = A1;

const byte pinPotRouge = A2;
const byte pinPotBleu = A3;
const byte pinPotJaune = A4;
const byte pinPotViolet = A5;
const byte pinPotGris = A6;

const byte pinPotIngredient1 = A7;
const byte pinPotIngredient2 = A8;
const byte pinPotIngredient3 = A9;
const byte pinPotIngredient4 = A10;
const byte pinPotIngredient5 = A11;
const byte pinPotIngredient6 = A12;
const byte pinPotIngredient7 = A13;

const int minPotQuantiteCouleur = 0;
const int maxPotQuantiteCouleur = 1023;

const int minPotQuantiteIngredient = 0;
const int maxPotQuantiteIngredient = 1023;

const int minPotRouge = 0;
const int maxPotRouge = 1023;

const int minPotBleu = 0;
const int maxPotBleu = 1023;

const int minPotJaune = 0;
const int maxPotJaune = 1023;

const int minPotViolet = 0;
const int maxPotViolet = 1023;

const int minPotGris = 0;
const int maxPotGris= 1023;

const int minPotIngredient1 = 0;
const int maxPotIngredient1 = 1023;

const int minPotIngredient2 = 0;
const int maxPotIngredient2 = 1023;

const int minPotIngredient3 = 0;
const int maxPotIngredient3 = 1023;

const int minPotIngredient4 = 0;
const int maxPotIngredient4 = 1023;

const int minPotIngredient5 = 0;
const int maxPotIngredient5 = 1023;

const int minPotIngredient6 = 0;
const int maxPotIngredient6 = 1023;

const int minPotIngredient7 = 0;
const int maxPotIngredient7 = 1023;

const int boutonPinEtatOn = LOW;     // Etat lu du bouton quand pressé (LOW pour PULL_UP)

const byte mpapDirPin = 24;     // Pour driver MPAP pin pas
const byte mpapStepPin = 25;     // Pour driver MPAP pin direction

const byte mpapDirPin2 = 26;     // Pour driver MPAP pin pas
const byte mpapStepPin2 = 27;     // Pour driver MPAP pin direction

const byte mpapDirPin3 = 30;     // Pour driver MPAP pin pas
const byte mpapStepPin3 = 31;     // Pour driver MPAP pin direction

const byte mpapDirPin4 = 28;     // Pour driver MPAP pin pas
const byte mpapStepPin4 = 22;     // Pour driver MPAP pin direction

const byte mpapDirPin5 = 47;     // Pour driver MPAP pin pas
const byte mpapStepPin5 = 45;     // Pour driver MPAP pin direction

const byte mpapDirPin6 = 5;     // Pour driver MPAP pin pas
const byte mpapStepPin6 = 6;     // Pour driver MPAP pin direction

const byte mpapDirPin7 = 2;     // Pour driver MPAP pin pas
const byte mpapStepPin7 = 7;     // Pour driver MPAP pin direction

const byte mpapDirPinRouge = 15;     // Pour driver MPAP pin pas
const byte mpapStepPinRouge = 14;     // Pour driver MPAP pin direction

const byte mpapDirPinBleu = 17;
const byte mpapStepPinBleu= 16;

const byte mpapDirPinJaune = 19;
const byte mpapStepPinJaune = 18;

const byte mpapDirPinViolet = 21;
const byte mpapStepPinViolet = 20;

const byte mpapDirPinGris = 39;
const byte mpapStepPinGris = 40;

AccelStepper MPAP1(1, mpapStepPin, mpapDirPin);     // 1 pour A4988
AccelStepper MPAP2(1, mpapStepPin2, mpapDirPin2);
AccelStepper MPAP3(1, mpapStepPin3, mpapDirPin3);
AccelStepper MPAP4(1, mpapStepPin4, mpapDirPin4);
AccelStepper MPAP5(1, mpapStepPin5, mpapDirPin5);
AccelStepper MPAP6(1, mpapStepPin6, mpapDirPin6);
AccelStepper MPAP7(1, mpapStepPin7, mpapDirPin7);

AccelStepper mpapRouge(1, mpapStepPinRouge, mpapDirPinRouge);
AccelStepper mpapBleu(1, mpapStepPinBleu, mpapDirPinBleu);
AccelStepper mpapJaune(1, mpapStepPinJaune, mpapDirPinJaune);
AccelStepper mpapViolet(1, mpapStepPinViolet, mpapDirPinViolet);
AccelStepper mpapGris(1, mpapStepPinGris, mpapDirPinGris);

int mpapNombreDePasAtourner = 200;

int ratio2(int nb3, int nb4,int nb5, int nb6, int nb7) {
  if ((nb3 == 0) && (nb4 == 0) && (nb5 == 0) && (nb6 == 0) && (nb7 == 0)) return 0;
  return (100.0 * nb3) / (nb3 + nb4 + nb5 + nb6 + nb7);
}

int ratio3(int nb8, int nb9, int nb10, int nb11, int nb12, int nb13, int nb14) {
  if ((nb8 == 0) && (nb9 == 0)&& (nb10 == 0) && (nb11 == 0) && (nb12 == 0) && (nb13 == 0) && (nb14 == 0)) return 0;
  return (100.0 * nb8) / (nb8 + nb9 + nb10 + nb11 + nb12 + nb13 + nb14);
}
  void marcheMpap1(void){
    
    MPAP1.move(CONTINUE);
    MPAP2.move(CONTINUE);
    MPAP3.move(CONTINUE);
    MPAP4.move(CONTINUE);
    MPAP5.move(CONTINUE);
    MPAP6.move(CONTINUE);
    MPAP7.move(CONTINUE);

    mpapRouge.move(CONTINUE);
    mpapBleu.move(CONTINUE);
    mpapJaune.move(CONTINUE);;
    mpapViolet.move(CONTINUE);
    mpapGris.move(CONTINUE);
  }
  void marcheMpap2(void){
    
    MPAP1.move(-CONTINUE);
    MPAP2.move(-CONTINUE);
    MPAP3.move(-CONTINUE);
    MPAP4.move(-CONTINUE);
    MPAP5.move(-CONTINUE);
    MPAP6.move(-CONTINUE);
    MPAP7.move(-CONTINUE);

    mpapRouge.move(-CONTINUE);
    mpapBleu.move(-CONTINUE);
    mpapJaune.move(-CONTINUE);;
    mpapViolet.move(-CONTINUE);
    mpapGris.move(-CONTINUE);
  }
    void arretMpap(void){
    MPAP1.stop();
    MPAP2.stop();
    MPAP3.stop();
    MPAP4.stop();
    MPAP5.stop();
    MPAP6.stop();
    MPAP7.stop();

    mpapRouge.stop();
    mpapBleu.stop();
    mpapJaune.stop();
    mpapViolet.stop();
    mpapGris.stop();
  }

MTcheckButton BoutonMarche(boutonMTcheck1, marcheMpap1, arretMpap);
MTcheckButton BoutonArret(boutonMTcheck2, marcheMpap2, arretMpap);

void setup()
{
  //pin d'affichage
  pinMode(boutonPinAffichage, INPUT_PULLUP);

  MPAP1.setMaxSpeed(400);
  MPAP1.setAcceleration(500);
  MPAP2.setMaxSpeed(400);
  MPAP2.setAcceleration(500);
  MPAP3.setMaxSpeed(400);
  MPAP3.setAcceleration(500);
  MPAP4.setMaxSpeed(400);
  MPAP4.setAcceleration(500);
  MPAP5.setMaxSpeed(400);
  MPAP5.setAcceleration(500);
  MPAP6.setMaxSpeed(400);
  MPAP6.setAcceleration(500);
  MPAP7.setMaxSpeed(400);
  MPAP7.setAcceleration(500);
  mpapRouge.setMaxSpeed(500);
  mpapRouge.setAcceleration(500);
  mpapBleu.setMaxSpeed(500);
  mpapBleu.setAcceleration(500);
  mpapJaune.setMaxSpeed(500);
  mpapJaune.setAcceleration(500);
  mpapViolet.setMaxSpeed(500);
  mpapViolet.setAcceleration(500);
  mpapGris.setMaxSpeed(500);
  mpapGris.setAcceleration(500);
  
  
  pinMode(boutonNemaIng1, INPUT_PULLUP);
  pinMode(boutonNemaIng2, INPUT_PULLUP);
  pinMode(boutonNemaIng3, INPUT_PULLUP);
  pinMode(boutonNemaIng4, INPUT_PULLUP);
  pinMode(boutonNemaIng5, INPUT_PULLUP);
  pinMode(boutonNemaIng6, INPUT_PULLUP);
  pinMode(boutonNemaIng7, INPUT_PULLUP);
  pinMode(boutonNemaRouge, INPUT_PULLUP);
  pinMode(boutonNemaBleu, INPUT_PULLUP);
  pinMode(boutonNemaJaune, INPUT_PULLUP);
  pinMode(boutonNemaViolet, INPUT_PULLUP);
  pinMode(boutonNemaGris, INPUT_PULLUP);

  pinMode(boutonMiseEnMarche, INPUT_PULLUP);
  pinMode(boutonArretDUrgence, INPUT_PULLUP);
  
  
  

  //mpap1.setEnablePin(mpapEnaPin);
  //                    DIR    STEP  ENA
  MPAP1.setPinsInverted(false, false, true);
  MPAP1.enableOutputs();     // Activer les signaux du MPAP
  MPAP2.setPinsInverted(false, false, true);
  MPAP2.enableOutputs();     // Activer les signaux du MPAP
  MPAP3.setPinsInverted(false, false, true);
  MPAP3.enableOutputs();     // Activer les signaux du MPAP
  MPAP4.setPinsInverted(false, false, true);
  MPAP4.enableOutputs();     // Activer les signaux du MPAP
  MPAP5.setPinsInverted(false, false, true);
  MPAP5.enableOutputs();     // Activer les signaux du MPAP
  MPAP6.setPinsInverted(false, false, true);
  MPAP6.enableOutputs();     // Activer les signaux du MPAP
  MPAP7.setPinsInverted(false, false, true);
  MPAP7.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  // // // // // // // // // // // // // // // 
  Serial.begin(115200);
}

void loop(){
  int quantiteCouleur = constrain(map(analogRead(pinPotQuantiteCouleur),minPotQuantiteCouleur,maxPotQuantiteCouleur,0,100),0,100);
  int quantiteIngredient = constrain(map(analogRead(pinPotQuantiteIngredient),minPotQuantiteIngredient,maxPotQuantiteIngredient,0,1000),0,1000);
  int rouge = constrain(map(analogRead(pinPotRouge), minPotRouge, maxPotRouge,  0, quantiteCouleur), 0, 100);
  int bleu = constrain(map(analogRead(pinPotBleu), minPotBleu, maxPotBleu, 0, quantiteCouleur), 0, 100);
  int jaune = constrain(map(analogRead(pinPotJaune), minPotJaune, maxPotJaune,  0, quantiteCouleur), 0, 100);
  int violet = constrain(map(analogRead(pinPotViolet), minPotViolet, maxPotViolet,  0, quantiteCouleur), 0, 100);
  int gris = constrain(map(analogRead(pinPotGris), minPotGris, maxPotGris,  0, quantiteCouleur), 0, 100);
  int Ingredient1 = constrain(map(analogRead(pinPotIngredient1), minPotIngredient1, maxPotIngredient1, 0, quantiteIngredient), 0, 100);
  int Ingredient2 = constrain(map(analogRead(pinPotIngredient2), minPotIngredient2, maxPotIngredient2, 0, quantiteIngredient), 0, 100);
  int Ingredient3 = constrain(map(analogRead(pinPotIngredient3), minPotIngredient3, maxPotIngredient3, 0, quantiteIngredient), 0, 100);
  int Ingredient4 = constrain(map(analogRead(pinPotIngredient4), minPotIngredient4, maxPotIngredient4, 0, quantiteIngredient), 0, 100);
  int Ingredient5 = constrain(map(analogRead(pinPotIngredient5), minPotIngredient5, maxPotIngredient5, 0, quantiteIngredient), 0, 100);
  int Ingredient6 = constrain(map(analogRead(pinPotIngredient6), minPotIngredient6, maxPotIngredient6, 0, quantiteIngredient), 0, 100);
  int Ingredient7 = constrain(map(analogRead(pinPotIngredient7), minPotIngredient7, maxPotIngredient7, 0, quantiteIngredient), 0, 100);
  
  int RatioRouge = ratio2(rouge, bleu, jaune, violet, gris);
  int RatioBleu = ratio2(bleu, rouge, jaune, violet, gris);
  int RatioJaune = ratio2(jaune, bleu, rouge, violet, gris);
  int RatioViolet = ratio2(violet, bleu, jaune, rouge, gris);
  int RatioGris = ratio2(gris, bleu, jaune, violet, rouge);
  int RatioIngredient1 = ratio3(Ingredient1, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient7);
  int RatioIngredient2 = ratio3(Ingredient2, Ingredient1, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient7);
  int RatioIngredient3 = ratio3(Ingredient3, Ingredient2, Ingredient1, Ingredient4, Ingredient5, Ingredient6, Ingredient7);
  int RatioIngredient4 = ratio3(Ingredient4, Ingredient2, Ingredient3, Ingredient1, Ingredient5, Ingredient6, Ingredient7);
  int RatioIngredient5 = ratio3(Ingredient5, Ingredient2, Ingredient3, Ingredient4, Ingredient1, Ingredient6, Ingredient7);
  int RatioIngredient6 = ratio3(Ingredient6, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient1, Ingredient7);
  int RatioIngredient7 = ratio3(Ingredient7, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient1);
 
  //Bouton de mise en marche des réglages
  boolean etatBoutonMiseEnMarche=digitalRead(boutonMiseEnMarche);
  if(etatBoutonMiseEnMarche == boutonPinEtatOn){
    
    routeRouge = mpapNombreDePasAtourner * RatioRouge;
    routeBleu = mpapNombreDePasAtourner * RatioBleu;
    routeJaune = mpapNombreDePasAtourner * RatioJaune;
    routeViolet = mpapNombreDePasAtourner * RatioViolet;
    routeGris = mpapNombreDePasAtourner * RatioGris;
    routeIngredient1 = mpapNombreDePasAtourner * RatioIngredient1;
    routeIngredient2 = mpapNombreDePasAtourner * RatioIngredient2;
    routeIngredient3 = mpapNombreDePasAtourner * RatioIngredient3;
    routeIngredient4 = mpapNombreDePasAtourner * RatioIngredient4;
    routeIngredient5 = mpapNombreDePasAtourner * RatioIngredient5;
    routeIngredient6 = mpapNombreDePasAtourner * RatioIngredient6;
    routeIngredient7 = mpapNombreDePasAtourner * RatioIngredient7;

    MPAP1.move(routeIngredient1);
    MPAP1.run();
    MPAP2.move(routeIngredient2);
    MPAP2.run();
    MPAP3.move(routeIngredient3);
    MPAP3.run();
    MPAP4.move(routeIngredient4);
    MPAP4.run();
    MPAP5.move(routeIngredient5);
    MPAP5.run();
    MPAP6.move(routeIngredient6);
    MPAP6.run();
    MPAP7.move(routeIngredient7);
    MPAP7.run();
    mpapRouge.move(routeRouge);
    mpapRouge.run();
    mpapBleu.move(routeBleu);
    mpapBleu.run();
    mpapJaune.move(routeJaune);
    mpapJaune.run();
    mpapViolet.move(routeViolet);
    mpapViolet.run();
    mpapGris.move(routeGris);
    mpapGris.run();
  }
  //Bouton d'arrêt d'urgence
  boolean etatBoutonArretDUrgence=digitalRead(boutonArretDUrgence);//variable booléenne du bouton d'arrêt d'urgence
  if(etatBoutonArretDUrgence == boutonPinEtatOn){
    MPAP1.stop();
    MPAP2.stop();
    MPAP3.stop();
    MPAP4.stop();
    MPAP5.stop();
    MPAP6.stop();
    MPAP7.stop();
    mpapRouge.stop();
    mpapBleu.stop();
    mpapJaune.stop();
    mpapViolet.stop();
    mpapGris.stop();
  }
  
  boolean etatBouton=digitalRead(boutonNemaIng1);
  if (etatBouton == boutonPinEtatOn)
  {
    
    MPAP1.move(mpapNombreDePasAtourner);
  }
  MPAP1.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton2=digitalRead(boutonNemaIng2);
  if (etatBouton2 == boutonPinEtatOn)
  {
    MPAP2.move(mpapNombreDePasAtourner);
  }
  MPAP2.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton3 = digitalRead(boutonNemaIng3);
  if (etatBouton3 == boutonPinEtatOn)
  {
    MPAP3.move(mpapNombreDePasAtourner);
  }
  MPAP3.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton4 = digitalRead(boutonNemaIng4);
  if (etatBouton4 == boutonPinEtatOn)
  {
    
    MPAP4.move(mpapNombreDePasAtourner);
  }
  MPAP4.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton5 = digitalRead(boutonNemaIng5);
  if (etatBouton5 == boutonPinEtatOn)
  {
    MPAP5.move(mpapNombreDePasAtourner);
  }
  MPAP5.run();
  // // // // // // // // // // // // // // //
  boolean etatBouton6 = digitalRead(boutonNemaIng6);
  if (etatBouton6 == boutonPinEtatOn)
  {
    MPAP6.move(mpapNombreDePasAtourner);
  }
  MPAP6.run();
  // // // // // // // // // // // // // // //
  boolean etatBouton7 = digitalRead(boutonNemaIng7);
  if (etatBouton7 == boutonPinEtatOn)
  {
    MPAP7.move(mpapNombreDePasAtourner);
  }
  MPAP7.run();
  // // // // // // // // // // // // // // //
  // // // // // // // // // // // // // // //
  boolean etatBouton11 = digitalRead(boutonNemaRouge);
  if (etatBouton11 == boutonPinEtatOn){
    mpapRouge.move(mpapNombreDePasAtourner);
  } 
  mpapRouge.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton12 = digitalRead(boutonNemaBleu);
  if (etatBouton12 == boutonPinEtatOn){
    Serial.println("etatBoutonMiseEnMarche est LOW ");
    mpapBleu.move(mpapNombreDePasAtourner);
  } 
  mpapBleu.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton13 = digitalRead(boutonNemaJaune);
  if (etatBouton13 == boutonPinEtatOn){
    mpapJaune.move(-mpapNombreDePasAtourner);
  } 
  mpapJaune.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton14 = digitalRead(boutonNemaViolet);
  if (etatBouton14 == boutonPinEtatOn){
    mpapViolet.move(mpapNombreDePasAtourner);
  } 
  mpapViolet.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton15 = digitalRead(boutonNemaGris);
  if (etatBouton15 == boutonPinEtatOn){
    mpapGris.move(mpapNombreDePasAtourner);
  } 
  mpapGris.run();
  
  
  //Bouton d'affichage
  boolean etatBoutonAffichage=digitalRead(boutonPinAffichage);
  if (etatBoutonAffichage == boutonPinEtatOn){
    Serial.println("etatBoutonMiseEnMarche est LOW ");
    Serial.print("Qte couleur:"); Serial.print(quantiteCouleur);  Serial.print(" gouttes |");
    Serial.print("Qte ingredient:");  Serial.print(quantiteIngredient); Serial.print(" ml |");
    Serial.print("rouge:");  Serial.print(ratio2(rouge, bleu, jaune, violet, gris)); Serial.print("% |");
    Serial.print("bleu:");  Serial.print(ratio2(bleu, rouge, jaune, violet, gris)); Serial.print("% |");
    Serial.print("jaune:");  Serial.print(ratio2(jaune, bleu, rouge, violet, gris)); Serial.print("% |");
    Serial.print("violet:");  Serial.print(ratio2(violet, bleu, jaune, rouge, gris)); Serial.print("% |");
    Serial.print("gris:");  Serial.print(ratio2(gris, bleu, jaune, violet, rouge)); Serial.print("% |");
    //////////////////////////////////////////////////////////////////////////////////////
    Serial.print("Ing1:");  Serial.print(ratio3(Ingredient1, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient7)); Serial.print("% |");
    Serial.print("Ing2:");  Serial.print(ratio3(Ingredient2, Ingredient1, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient7)); Serial.print("% |");
    Serial.print("Ing3:");  Serial.print(ratio3(Ingredient3, Ingredient2, Ingredient1, Ingredient4, Ingredient5, Ingredient6, Ingredient7)); Serial.print("% |");
    Serial.print("Ing4:");  Serial.print(ratio3(Ingredient4, Ingredient2, Ingredient3, Ingredient1, Ingredient5, Ingredient6, Ingredient7)); Serial.print("% |");
    Serial.print("Ing5:");  Serial.print(ratio3(Ingredient5, Ingredient2, Ingredient3, Ingredient4, Ingredient1, Ingredient6, Ingredient7)); Serial.print("% |");
    Serial.print("Ing6:");  Serial.print(ratio3(Ingredient6, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient1, Ingredient7)); Serial.print("% |");
    Serial.print("Ing7:");  Serial.print(ratio3(Ingredient7, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient1)); Serial.println("%");
    delay(700);
    
  }
}

Cordialement

Je mesure pour un seul moteur une vitesse de 161 pas/s, ceci est sans doute dû à loop() qui est longue et qui n'appelle la fonction run() que 161 fois par seconde. En faisant tourner tous les moteurs en même temps, je trouve qu'ils tournent à 110 pas/s. On est donc en dessous des 400pas/s demandés, ce qui n'est pas forcément grave.


Je vois aussi que BoutonMarche fait tourner tous les moteurs si on appuie une fois dessus, et les arrête si on rappuie. BoutonArret fait pareil mais dans l'autre sens. Soit ce fonctionnement est voulu, et il vaut mieux appeler ces boutons BoutonMarcheAvant et BoutonMarcheArrière ou quelque chose comme cela, soit ce n'est pas ce qui est voulu, auquel cas dis nous ce que tu veux faire.
Note: en fait ces noms n'apparaissent qu'une seule fois, ils ne servent que comme commentaire.


A propos de commentaires: `#include "AccelStepper.h"` est compréhensible par énormément de gens, pas besoin de commentaires `#include "MTcheckButton.h"` ne dira pas grand chose pour la pluspart des gens. Il vau mieux laisser le commentaire derrière, ceci permet de trouver la doc et le chargement (on devrait d'ailleurs le faire pour toutes les bibliothèques, cela permettrait de retrouver leur provenance. Si 100 personnes font une librairie pour gérer un MachinTrucChose, une grande partie d'entre eux vont utiliser `#include "MachinTrucChose.h"` et personne ne poura dire quelle bibliothèque est choisie). Laissons `#include "MTbutton.h" // V1.0.0 Voir http://arduino.dansetrad.fr/MTobjects`
Je pense que: En mettant tous les potentiomètres au milieu, ratio 2 devrait retourner 20 et ratio3 devrait retourner 14. En conséquence: ~ RatioIngredientX doit valoir 14*200 soit 14 tours, si ce moteur tourne seul, il tourne à 160pas/s il va tourner 17,5s ~ RatioRouge est prévu pour faire 20 tours de moteurs et va durer 25s ~ Si on teste seulement le rouge (les autres potentiomètres à 0), on demande alors de tourner 100 tours soit pendant 2 minutes. Est-ce-bien cela qui est voulu?

J'observe un fonctionnement correct (mais j'ai mis 20 au lieu de 200 pour ne pas avoir à attendre 2 mn pour l'arrêt.
Question: as-tu attendu les 2 mn?

A priori, il n'y a pas de mémorisation sur les boutons dédiés. Si c'est des poussoirs, ce devrait être impossible.


En mettant que du rouge, on va demander 20 tours. Le bouton dédié devrait fonctionner ainsi:
Tant que j'appuie, le moteur rouge tourne. Au relâchement, il commence ses 20 tours. Si j'appuie donc rapidement dessus, je vais avoir 20 tours, si je suis lent je vais avoir 21 ou 22 tours.
Question: c'est bien cela que tu veux?


Effectivement je n'avais pas vu qu'il était sur les sorties utilisées par Serial.print()
Pour la vitesse, le programmes est le même pour tous les ingrédients. La cause la plus probable est une broche MS1 à MS3 de son A4988 qui est à 5V ou reliée à une autre broche. Tourne-t-il exactement deux fois moins vite? 4 fois moins vite?

Chez moi, ils fonctionnent. La cause la plus probable est une breadboard dont les fils d'alimentation ne vont pas d'un côté à l'autre mais sont interrompus au milieu. La moitié des breadboard ont les 4 fils externes qui vont d'un côté à l'autre, l'autre moitié on des fils divisés en deux. Vérifie que la masse des bouton est bien reliée.

Bonjour
Effectivement, je dois renommer BoutonMarche et BoutonArret car ces fonctionnements sont voulus.

MTcheckButton BoutonMarcheAvant(boutonMTcheck1, marcheMpap1, arretMpap);
MTcheckButton BoutonMarcheArriere(boutonMTcheck2, marcheMpap2, arretMpap);

Je ne suis pas sur que si l'on met tous les potentiomètre au milieu, le ratio 2 devrait retourner 20 et ratio3 devrait retourner 14 mais je croit que c'est bien ce qui est voulu. Si par exemple le ratio 2 est à 24% alors le moteur 2 doit effectué 24 multiplié par nombre de pas dans le programme. Peut être dois je préciser que j'ai voulu élargir l'affichage dans le moniteur série en me servant du programme suivant:

const byte pinPotQuantiteCouleur = A0;
const byte pinPotQuantiteIngredient = A1;

const byte pinPotRouge = A2;
const byte pinPotBleu = A3;
const byte pinPotJaune = A4;
const byte pinPotViolet = A5;
const byte pinPotGris = A6;

const byte pinPotIngredient1 = A7;
const byte pinPotIngredient2 = A8;
const byte pinPotIngredient3 = A9;
const byte pinPotIngredient4 = A10;
const byte pinPotIngredient5 = A11;
const byte pinPotIngredient6 = A12;
const byte pinPotIngredient7 = A13;

const int minPotQuantiteCouleur = 0;
const int maxPotQuantiteCouleur = 1023;

const int minPotQuantiteIngredient = 0;
const int maxPotQuantiteIngredient = 1023;

const int minPotRouge = 0;
const int maxPotRouge = 1023;

const int minPotBleu = 0;
const int maxPotBleu = 1023;

const int minPotJaune = 0;
const int maxPotJaune = 1023;

const int minPotViolet = 0;
const int maxPotViolet = 1023;

const int minPotGris = 0;
const int maxPotGris = 1023;

const int minPotIngredient1 = 0;
const int maxPotIngredient1 = 1023;

const int minPotIngredient2 = 0;
const int maxPotIngredient2 = 1023;

const int minPotIngredient3 = 0;
const int maxPotIngredient3 = 1023;

const int minPotIngredient4 = 0;
const int maxPotIngredient4 = 1023;

const int minPotIngredient5 = 0;
const int maxPotIngredient5 = 1023;

const int minPotIngredient6 = 0;
const int maxPotIngredient6 = 1023;

const int minPotIngredient7 = 0;
const int maxPotIngredient7 = 1023;

int ratio2(int nb3, int nb4,int nb5, int nb6, int nb7) {
  if ((nb3 == 0) && (nb4 == 0) && (nb5 == 0) && (nb6 == 0) && (nb7 == 0)) return 0;
  return (100.0 * nb3) / (nb3 + nb4 + nb5 + nb6 + nb7);
}

int ratio3(int nb8, int nb9, int nb10, int nb11, int nb12, int nb13, int nb14) {
  if ((nb8 == 0) && (nb9 == 0)&& (nb10 == 0) && (nb11 == 0) && (nb12 == 0) && (nb13 == 0) && (nb14 == 0)) return 0;
  return (100.0 * nb8) / (nb8 + nb9 + nb10 + nb11 + nb12 + nb13 + nb14);
}

void setup() {
  Serial.begin(115200);
}

void loop() {
  int quantiteCouleur = constrain(map(analogRead(pinPotQuantiteCouleur),minPotQuantiteCouleur,maxPotQuantiteCouleur,0,100),0,100);
  int quantiteIngredient = constrain(map(analogRead(pinPotQuantiteIngredient),minPotQuantiteIngredient,maxPotQuantiteIngredient,0,1000),0,1000);
  int rouge = constrain(map(analogRead(pinPotRouge), minPotRouge, maxPotRouge,  0, quantiteCouleur), 0, 100);
  int bleu = constrain(map(analogRead(pinPotBleu), minPotBleu, maxPotBleu, 0, quantiteCouleur), 0, 100);
  int jaune = constrain(map(analogRead(pinPotJaune), minPotJaune, maxPotJaune,  0, quantiteCouleur), 0, 100);
  int violet = constrain(map(analogRead(pinPotViolet), minPotViolet, maxPotViolet,  0, quantiteCouleur), 0, 100);
  int gris = constrain(map(analogRead(pinPotGris), minPotGris, maxPotGris,  0, quantiteCouleur), 0, 100);
  int Ingredient1 = constrain(map(analogRead(pinPotIngredient1), minPotIngredient1, maxPotIngredient1, 0, quantiteIngredient), 0, 100);
  int Ingredient2 = constrain(map(analogRead(pinPotIngredient2), minPotIngredient2, maxPotIngredient2, 0, quantiteIngredient), 0, 100);
  int Ingredient3 = constrain(map(analogRead(pinPotIngredient3), minPotIngredient3, maxPotIngredient3, 0, quantiteIngredient), 0, 100);
  int Ingredient4 = constrain(map(analogRead(pinPotIngredient4), minPotIngredient4, maxPotIngredient4, 0, quantiteIngredient), 0, 100);
  int Ingredient5 = constrain(map(analogRead(pinPotIngredient5), minPotIngredient5, maxPotIngredient5, 0, quantiteIngredient), 0, 100);
  int Ingredient6 = constrain(map(analogRead(pinPotIngredient6), minPotIngredient6, maxPotIngredient6, 0, quantiteIngredient), 0, 100);
  int Ingredient7 = constrain(map(analogRead(pinPotIngredient7), minPotIngredient7, maxPotIngredient7, 0, quantiteIngredient), 0, 100);
  //////////////////////////////////////////////////////////////////////////////////////
  Serial.print("Qte couleur:"); Serial.print(quantiteCouleur);  Serial.print(" gouttes |");
  Serial.print("Qte Ingredient:");  Serial.print(quantiteIngredient); Serial.print(" ml |");
  Serial.print("rouge:");  Serial.print(ratio2(rouge, bleu, jaune, violet, gris)); Serial.print("% |");
  Serial.print("bleu:");  Serial.print(ratio2(bleu, rouge, jaune, violet, gris)); Serial.print("% |");
  Serial.print("jaune:");  Serial.print(ratio2(jaune, bleu, rouge, violet, gris)); Serial.print("% |");
  Serial.print("violet:");  Serial.print(ratio2(violet, bleu, jaune, rouge, gris)); Serial.print("% |");
  Serial.print("gris:");  Serial.print(ratio2(gris, bleu, jaune, violet, rouge)); Serial.print("% |");
  //////////////////////////////////////////////////////////////////////////////////////
  Serial.print("Ing1:");  Serial.print(ratio3(Ingredient1, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient7)); Serial.print("% |");
  Serial.print("Ing2:");  Serial.print(ratio3(Ingredient2, Ingredient1, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient7)); Serial.print("% |");
  Serial.print("Ing3:");  Serial.print(ratio3(Ingredient3, Ingredient2, Ingredient1, Ingredient4, Ingredient5, Ingredient6, Ingredient7)); Serial.print("% |");
  Serial.print("Ing4:");  Serial.print(ratio3(Ingredient4, Ingredient2, Ingredient3, Ingredient1, Ingredient5, Ingredient6, Ingredient7)); Serial.print("% |");
  Serial.print("Ing5:");  Serial.print(ratio3(Ingredient5, Ingredient2, Ingredient3, Ingredient4, Ingredient1, Ingredient6, Ingredient7)); Serial.print("% |");
  Serial.print("Ing6:");  Serial.print(ratio3(Ingredient6, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient1, Ingredient7)); Serial.print("% |");
  Serial.print("Ing7:");  Serial.print(ratio3(Ingredient7, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient1)); Serial.println("%");
  delay(700);
}

J'aurais voulu mesurer correctement le temps qu'il faut à un moteur pour tourner mais malheureusement j'utilise un adaptateur et des fils sur une alimentation 12V qui fait fumer et fondre les fils très vite:


Je peux dire que lorsque j'ai arrêter, j'en était à une minute de mon coté. Ce sont bien des boutons poussoir qui sont utilisés sur mes breadbords.

En mettant que du rouge, on va demander 20 tours. Le bouton dédié devrait fonctionner ainsi:
Tant que j'appuie, le moteur rouge tourne. Au relâchement, il commence ses 20 tours. Si j'appuie donc rapidement dessus, je vais avoir 20 tours, si je suis lent je vais avoir 21 ou 22 tours.
Question: c'est bien cela que tu veux?

Non. Concernant les boutons dédiés à chaque moteur, tant que l'on reste appuyé sur le bouton d'un moteur, celui ci doit continuer de tourner et si on le relâche ils doit cesser de tourner comme pour le code suivant composé seulement de accelstepper:

#include "AccelStepper.h"     // https://www.pjrc.com/teensy/td_libs_AccelStepper.html

const byte boutonNemaIng1 = 32;
const byte boutonNemaIng2 = 34;
const byte boutonNemaIng3 = 33;
const byte boutonNemaIng4 = 52;
const byte boutonNemaIng5 = 53;
const byte boutonNemaIng6 = 3;
const byte boutonNemaIng7 = 4;

const byte boutonNemaRouge = 35;
const byte boutonNemaBleu = 36;
const byte boutonNemaJaune = 38;
const byte boutonNemaViolet = 51;
const byte boutonNemaGris = 29;

const int boutonPinEtatOn = LOW;     // Etat lu du bouton quand pressé (LOW pour PULL_UP)

const byte mpapDirPin = 24;     
const byte mpapStepPin = 25;     

const byte mpapDirPin2 = 26;    
const byte mpapStepPin2 = 27;     

const byte mpapDirPin3 = 30;     
const byte mpapStepPin3 = 31;    

const byte mpapDirPin4 = 28;    
const byte mpapStepPin4 = 22;    

const byte mpapDirPin5 = 0;    
const byte mpapStepPin5 = 1;   

const byte mpapDirPin6 = 5;     
const byte mpapStepPin6 = 6;     

const byte mpapDirPin7 = 2;     
const byte mpapStepPin7 = 7; 

const byte mpapDirPinRouge = 15;   
const byte mpapStepPinRouge = 14;    

const byte mpapDirPinBleu = 17;
const byte mpapStepPinBleu = 16;

const byte mpapDirPinJaune = 19;
const byte mpapStepPinJaune = 18;

const byte mpapDirPinViolet = 21;
const byte mpapStepPinViolet = 20;

const byte mpapDirPinGris = 39;
const byte mpapStepPinGris = 40;



AccelStepper MPAP1(1, mpapStepPin, mpapDirPin);     // 1 pour A4988
AccelStepper MPAP2(1, mpapStepPin2, mpapDirPin2);
AccelStepper MPAP3(1, mpapStepPin3, mpapDirPin3);
AccelStepper MPAP4(1, mpapStepPin4, mpapDirPin4);
AccelStepper MPAP5(1, mpapStepPin5, mpapDirPin5);
AccelStepper MPAP6(1, mpapStepPin6, mpapDirPin6);
AccelStepper MPAP7(1, mpapStepPin7, mpapDirPin7);

AccelStepper mpapRouge(1, mpapStepPinRouge, mpapDirPinRouge);
AccelStepper mpapBleu(1, mpapStepPinBleu, mpapDirPinBleu);
AccelStepper mpapJaune(1, mpapStepPinJaune, mpapDirPinJaune);
AccelStepper mpapViolet(1, mpapStepPinViolet, mpapDirPinViolet);
AccelStepper mpapGris(1, mpapStepPinGris, mpapDirPinGris); 

int mpapNombreDePasAtourner = 100;

void setup()
{
  MPAP1.setMaxSpeed(400);
  MPAP1.setAcceleration(500);
  
  pinMode(boutonNemaIng1, INPUT_PULLUP);

  //mpap1.setEnablePin(mpapEnaPin);
  //                    DIR    STEP  ENA
  MPAP1.setPinsInverted(false, false, true);
  MPAP1.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  MPAP2.setMaxSpeed(400);
  MPAP2.setAcceleration(500);

  pinMode(boutonNemaIng2, INPUT_PULLUP);

  MPAP2.setPinsInverted(false, false, true);
  MPAP2.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  MPAP3.setMaxSpeed(400);
  MPAP3.setAcceleration(500);

  pinMode(boutonNemaIng3, INPUT_PULLUP);

  MPAP3.setPinsInverted(false, false, true);
  MPAP3.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  MPAP4.setMaxSpeed(400);
  MPAP4.setAcceleration(500);

  pinMode(boutonNemaIng4, INPUT_PULLUP);

  MPAP4.setPinsInverted(false, false, true);
  MPAP4.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  MPAP5.setMaxSpeed(400);
  MPAP5.setAcceleration(500);

  pinMode(boutonNemaIng5, INPUT_PULLUP);

  MPAP5.setPinsInverted(false, false, true);
  MPAP5.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  MPAP6.setMaxSpeed(400);
  MPAP6.setAcceleration(500);

  pinMode(boutonNemaIng6, INPUT_PULLUP);

  MPAP6.setPinsInverted(false, false, true);
  MPAP6.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  MPAP7.setMaxSpeed(400);
  MPAP7.setAcceleration(500);

  pinMode(boutonNemaIng7, INPUT_PULLUP);

  MPAP7.setPinsInverted(false, false, true);
  MPAP7.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  // // // // // // // // // // // // // // // 
  mpapRouge.setMaxSpeed(500);
  mpapRouge.setAcceleration(500);

  pinMode(boutonNemaRouge, INPUT_PULLUP);
  // // // // // // // // // // // // // // //
  mpapBleu.setMaxSpeed(500);
  mpapBleu.setAcceleration(500);

  pinMode(boutonNemaBleu, INPUT_PULLUP);
  // // // // // // // // // // // // // // //
  mpapJaune.setMaxSpeed(500);
  mpapJaune.setAcceleration(500);

  pinMode(boutonNemaJaune, INPUT_PULLUP);
  // // // // // // // // // // // // // // //
  mpapViolet.setMaxSpeed(500);
  mpapViolet.setAcceleration(500);

  pinMode(boutonNemaViolet, INPUT_PULLUP);
  // // // // // // // // // // // // // // //
  mpapGris.setMaxSpeed(500);
  mpapGris.setAcceleration(500);

  pinMode(boutonNemaGris, INPUT_PULLUP);
}

void loop()
{
  boolean etatBouton=digitalRead(boutonNemaIng1);
  if (etatBouton == boutonPinEtatOn)
  {
    MPAP1.move(mpapNombreDePasAtourner);
  }
  MPAP1.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton2=digitalRead(boutonNemaIng2);
  if (etatBouton2 == boutonPinEtatOn)
  {
    MPAP2.move(mpapNombreDePasAtourner);
  }
  MPAP2.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton3 = digitalRead(boutonNemaIng3);
  if (etatBouton3 == boutonPinEtatOn)
  {
    MPAP3.move(mpapNombreDePasAtourner);
  }
  MPAP3.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton4 = digitalRead(boutonNemaIng4);
  if (etatBouton4 == boutonPinEtatOn)
  {
    MPAP4.move(mpapNombreDePasAtourner);
  }
  MPAP4.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton5 = digitalRead(boutonNemaIng5);
  if (etatBouton5 == boutonPinEtatOn)
  {
    MPAP5.move(mpapNombreDePasAtourner);
  }
  MPAP5.run();
  // // // // // // // // // // // // // // //
  boolean etatBouton6 = digitalRead(boutonNemaIng6);
  if (etatBouton6 == boutonPinEtatOn)
  {
    MPAP6.move(mpapNombreDePasAtourner);
  }
  MPAP6.run();
  // // // // // // // // // // // // // // //
  boolean etatBouton7 = digitalRead(boutonNemaIng7);
  if (etatBouton7 == boutonPinEtatOn)
  {
    MPAP7.move(mpapNombreDePasAtourner);
  }
  MPAP7.run();
  // // // // // // // // // // // // // // //
  // // // // // // // // // // // // // // //
  boolean etatBouton11 = digitalRead(boutonNemaRouge);
  if (etatBouton11 == boutonPinEtatOn){
    mpapRouge.move(mpapNombreDePasAtourner);
  } 
  mpapRouge.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton12 = digitalRead(boutonNemaBleu);
  if (etatBouton12 == boutonPinEtatOn){
    mpapBleu.move(mpapNombreDePasAtourner);
  } 
  mpapBleu.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton13 = digitalRead(boutonNemaJaune);
  if (etatBouton13 == boutonPinEtatOn){
    mpapJaune.move(-mpapNombreDePasAtourner);
  } 
  mpapJaune.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton14 = digitalRead(boutonNemaViolet);
  if (etatBouton14 == boutonPinEtatOn){
    mpapViolet.move(mpapNombreDePasAtourner);
  } 
  mpapViolet.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton15 = digitalRead(boutonNemaGris);
  if (etatBouton15 == boutonPinEtatOn){
    mpapGris.move(mpapNombreDePasAtourner);
  } 
  mpapGris.run();
}

le bouton d'affichage doit servir à afficher les ratios des potentiomètres tant que l'on reste appuyé dessus, le bouton de mise en marche avant doit mettre tous les moteurs en marche avant en même temps et à l'infini lorsque l'on appuie dessus une première fois et les arrêter lorsque l'on rappuie dessus. Pareil pour le bouton de mise en marche arrière mais dans l'autre sens. Le bouton de mise en route dois faire tourner tous les moteurs en même temps du même nombre de fois que le ratio qui leur est dédié multiplié par le nombre de pas dans le programme et le bouton d'arrêt d'urgence doit les arrêter si on a appuyé sur le bouton de mise en route.
J'ai revérifié les branchement du 5 ème A4988 et le step est bien à la broche 45, le dir à 47, et le reste branché comme les autres driver.
image
Je dirais que le moteur 5 tourne 2 à 3 fois moins vite.
J'ai revérifié les branchements des fils du bouton d'affichage: un fils part de la broche 12 jusqu'à une extrémité du bouton puis à l'extrémité d'a coté, un autre fils part au ground du coté des condensateurs et il ne fonctionne toujours pas chez moi. Le programme affiche bien dans le setup que la broche 12 est en input_pullup. Mes breadbords ne peuvent pas être coupées au milieu car il s'agit cette fois de solderless breadboard de chez elegoo dont je me suis assuré l'absence de coupure au milieu à l'aide de LED


breadboard.jpg (640×270) (pjrc.com)
Voici le programme:

#include "AccelStepper.h"
#include "MTcheckButton.h"
#include "MTstepStepper.h"
#include "MTbutton.h" // V1.0.0 Voir http://arduino.dansetrad.fr/MTobjects


const byte boutonMTcheck1 = 50;
const byte boutonMTcheck2 = 51;

const byte boutonNemaIng1 = 32;
const byte boutonNemaIng2 = 34;
const byte boutonNemaIng3 = 33;
const byte boutonNemaIng4 = 52;
const byte boutonNemaIng5 = 53;
const byte boutonNemaIng6 = 3;
const byte boutonNemaIng7 = 4;

const byte boutonNemaRouge = 35;
const byte boutonNemaBleu = 36;
const byte boutonNemaJaune = 38;
const byte boutonNemaViolet = 49;
const byte boutonNemaGris = 29;

const byte boutonPinAffichage = 12;

const byte boutonMiseEnMarche = 8;

const byte boutonArretDUrgence = 18;

int routeRouge = 0;
int routeBleu = 0;
int routeJaune = 0;
int routeViolet = 0;
int routeGris = 0;
int routeIngredient1 = 0;
int routeIngredient2 = 0;
int routeIngredient3 = 0;
int routeIngredient4 = 0;
int routeIngredient5 = 0;
int routeIngredient6 = 0;
int routeIngredient7 = 0;


const byte pinPotQuantiteCouleur = A0;
const byte pinPotQuantiteIngredient = A1;

const byte pinPotRouge = A2;
const byte pinPotBleu = A3;
const byte pinPotJaune = A4;
const byte pinPotViolet = A5;
const byte pinPotGris = A6;

const byte pinPotIngredient1 = A7;
const byte pinPotIngredient2 = A8;
const byte pinPotIngredient3 = A9;
const byte pinPotIngredient4 = A10;
const byte pinPotIngredient5 = A11;
const byte pinPotIngredient6 = A12;
const byte pinPotIngredient7 = A13;

const int minPotQuantiteCouleur = 0;
const int maxPotQuantiteCouleur = 1023;

const int minPotQuantiteIngredient = 0;
const int maxPotQuantiteIngredient = 1023;

const int minPotRouge = 0;
const int maxPotRouge = 1023;

const int minPotBleu = 0;
const int maxPotBleu = 1023;

const int minPotJaune = 0;
const int maxPotJaune = 1023;

const int minPotViolet = 0;
const int maxPotViolet = 1023;

const int minPotGris = 0;
const int maxPotGris= 1023;

const int minPotIngredient1 = 0;
const int maxPotIngredient1 = 1023;

const int minPotIngredient2 = 0;
const int maxPotIngredient2 = 1023;

const int minPotIngredient3 = 0;
const int maxPotIngredient3 = 1023;

const int minPotIngredient4 = 0;
const int maxPotIngredient4 = 1023;

const int minPotIngredient5 = 0;
const int maxPotIngredient5 = 1023;

const int minPotIngredient6 = 0;
const int maxPotIngredient6 = 1023;

const int minPotIngredient7 = 0;
const int maxPotIngredient7 = 1023;

const int boutonPinEtatOn = LOW;     // Etat lu du bouton quand pressé (LOW pour PULL_UP)

const byte mpapDirPin = 24;     // Pour driver MPAP pin pas
const byte mpapStepPin = 25;     // Pour driver MPAP pin direction

const byte mpapDirPin2 = 26;     // Pour driver MPAP pin pas
const byte mpapStepPin2 = 27;     // Pour driver MPAP pin direction

const byte mpapDirPin3 = 30;     // Pour driver MPAP pin pas
const byte mpapStepPin3 = 31;     // Pour driver MPAP pin direction

const byte mpapDirPin4 = 28;     // Pour driver MPAP pin pas
const byte mpapStepPin4 = 22;     // Pour driver MPAP pin direction

const byte mpapDirPin5 = 47;     // Pour driver MPAP pin pas
const byte mpapStepPin5 = 45;     // Pour driver MPAP pin direction

const byte mpapDirPin6 = 5;     // Pour driver MPAP pin pas
const byte mpapStepPin6 = 6;     // Pour driver MPAP pin direction

const byte mpapDirPin7 = 2;     // Pour driver MPAP pin pas
const byte mpapStepPin7 = 7;     // Pour driver MPAP pin direction

const byte mpapDirPinRouge = 15;     // Pour driver MPAP pin pas
const byte mpapStepPinRouge = 14;     // Pour driver MPAP pin direction

const byte mpapDirPinBleu = 17;
const byte mpapStepPinBleu= 16;

const byte mpapDirPinJaune = 19;
const byte mpapStepPinJaune = 18;

const byte mpapDirPinViolet = 21;
const byte mpapStepPinViolet = 20;

const byte mpapDirPinGris = 39;
const byte mpapStepPinGris = 40;

AccelStepper MPAP1(1, mpapStepPin, mpapDirPin);     // 1 pour A4988
AccelStepper MPAP2(1, mpapStepPin2, mpapDirPin2);
AccelStepper MPAP3(1, mpapStepPin3, mpapDirPin3);
AccelStepper MPAP4(1, mpapStepPin4, mpapDirPin4);
AccelStepper MPAP5(1, mpapStepPin5, mpapDirPin5);
AccelStepper MPAP6(1, mpapStepPin6, mpapDirPin6);
AccelStepper MPAP7(1, mpapStepPin7, mpapDirPin7);

AccelStepper mpapRouge(1, mpapStepPinRouge, mpapDirPinRouge);
AccelStepper mpapBleu(1, mpapStepPinBleu, mpapDirPinBleu);
AccelStepper mpapJaune(1, mpapStepPinJaune, mpapDirPinJaune);
AccelStepper mpapViolet(1, mpapStepPinViolet, mpapDirPinViolet);
AccelStepper mpapGris(1, mpapStepPinGris, mpapDirPinGris);

int mpapNombreDePasAtourner = 200;

int ratio2(int nb3, int nb4,int nb5, int nb6, int nb7) {
  if ((nb3 == 0) && (nb4 == 0) && (nb5 == 0) && (nb6 == 0) && (nb7 == 0)) return 0;
  return (100.0 * nb3) / (nb3 + nb4 + nb5 + nb6 + nb7);
}

int ratio3(int nb8, int nb9, int nb10, int nb11, int nb12, int nb13, int nb14) {
  if ((nb8 == 0) && (nb9 == 0)&& (nb10 == 0) && (nb11 == 0) && (nb12 == 0) && (nb13 == 0) && (nb14 == 0)) return 0;
  return (100.0 * nb8) / (nb8 + nb9 + nb10 + nb11 + nb12 + nb13 + nb14);
}
  void marcheMpap1(void){
    
    MPAP1.move(CONTINUE);
    MPAP2.move(CONTINUE);
    MPAP3.move(CONTINUE);
    MPAP4.move(CONTINUE);
    MPAP5.move(CONTINUE);
    MPAP6.move(CONTINUE);
    MPAP7.move(CONTINUE);

    mpapRouge.move(CONTINUE);
    mpapBleu.move(CONTINUE);
    mpapJaune.move(CONTINUE);;
    mpapViolet.move(CONTINUE);
    mpapGris.move(CONTINUE);
  }
  void marcheMpap2(void){
    
    MPAP1.move(-CONTINUE);
    MPAP2.move(-CONTINUE);
    MPAP3.move(-CONTINUE);
    MPAP4.move(-CONTINUE);
    MPAP5.move(-CONTINUE);
    MPAP6.move(-CONTINUE);
    MPAP7.move(-CONTINUE);

    mpapRouge.move(-CONTINUE);
    mpapBleu.move(-CONTINUE);
    mpapJaune.move(-CONTINUE);;
    mpapViolet.move(-CONTINUE);
    mpapGris.move(-CONTINUE);
  }
    void arretMpap(void){
    MPAP1.stop();
    MPAP2.stop();
    MPAP3.stop();
    MPAP4.stop();
    MPAP5.stop();
    MPAP6.stop();
    MPAP7.stop();

    mpapRouge.stop();
    mpapBleu.stop();
    mpapJaune.stop();
    mpapViolet.stop();
    mpapGris.stop();
  }

MTcheckButton BoutonMarcheAvant(boutonMTcheck1, marcheMpap1, arretMpap);
MTcheckButton BoutonMarcheArriere(boutonMTcheck2, marcheMpap2, arretMpap);

void setup()
{
  //pin d'affichage
  pinMode(boutonPinAffichage, INPUT_PULLUP);

  MPAP1.setMaxSpeed(400);
  MPAP1.setAcceleration(500);
  MPAP2.setMaxSpeed(400);
  MPAP2.setAcceleration(500);
  MPAP3.setMaxSpeed(400);
  MPAP3.setAcceleration(500);
  MPAP4.setMaxSpeed(400);
  MPAP4.setAcceleration(500);
  MPAP5.setMaxSpeed(400);
  MPAP5.setAcceleration(500);
  MPAP6.setMaxSpeed(400);
  MPAP6.setAcceleration(500);
  MPAP7.setMaxSpeed(400);
  MPAP7.setAcceleration(500);
  mpapRouge.setMaxSpeed(500);
  mpapRouge.setAcceleration(500);
  mpapBleu.setMaxSpeed(500);
  mpapBleu.setAcceleration(500);
  mpapJaune.setMaxSpeed(500);
  mpapJaune.setAcceleration(500);
  mpapViolet.setMaxSpeed(500);
  mpapViolet.setAcceleration(500);
  mpapGris.setMaxSpeed(500);
  mpapGris.setAcceleration(500);
  
  
  pinMode(boutonNemaIng1, INPUT_PULLUP);
  pinMode(boutonNemaIng2, INPUT_PULLUP);
  pinMode(boutonNemaIng3, INPUT_PULLUP);
  pinMode(boutonNemaIng4, INPUT_PULLUP);
  pinMode(boutonNemaIng5, INPUT_PULLUP);
  pinMode(boutonNemaIng6, INPUT_PULLUP);
  pinMode(boutonNemaIng7, INPUT_PULLUP);
  pinMode(boutonNemaRouge, INPUT_PULLUP);
  pinMode(boutonNemaBleu, INPUT_PULLUP);
  pinMode(boutonNemaJaune, INPUT_PULLUP);
  pinMode(boutonNemaViolet, INPUT_PULLUP);
  pinMode(boutonNemaGris, INPUT_PULLUP);

  pinMode(boutonMiseEnMarche, INPUT_PULLUP);
  pinMode(boutonArretDUrgence, INPUT_PULLUP);
  
  
  

  //mpap1.setEnablePin(mpapEnaPin);
  //                    DIR    STEP  ENA
  MPAP1.setPinsInverted(false, false, true);
  MPAP1.enableOutputs();     // Activer les signaux du MPAP
  MPAP2.setPinsInverted(false, false, true);
  MPAP2.enableOutputs();     // Activer les signaux du MPAP
  MPAP3.setPinsInverted(false, false, true);
  MPAP3.enableOutputs();     // Activer les signaux du MPAP
  MPAP4.setPinsInverted(false, false, true);
  MPAP4.enableOutputs();     // Activer les signaux du MPAP
  MPAP5.setPinsInverted(false, false, true);
  MPAP5.enableOutputs();     // Activer les signaux du MPAP
  MPAP6.setPinsInverted(false, false, true);
  MPAP6.enableOutputs();     // Activer les signaux du MPAP
  MPAP7.setPinsInverted(false, false, true);
  MPAP7.enableOutputs();     // Activer les signaux du MPAP
  // // // // // // // // // // // // // // // 
  // // // // // // // // // // // // // // // 
  Serial.begin(115200);
}

void loop(){
  int quantiteCouleur = constrain(map(analogRead(pinPotQuantiteCouleur),minPotQuantiteCouleur,maxPotQuantiteCouleur,0,100),0,100);
  int quantiteIngredient = constrain(map(analogRead(pinPotQuantiteIngredient),minPotQuantiteIngredient,maxPotQuantiteIngredient,0,1000),0,1000);
  int rouge = constrain(map(analogRead(pinPotRouge), minPotRouge, maxPotRouge,  0, quantiteCouleur), 0, 100);
  int bleu = constrain(map(analogRead(pinPotBleu), minPotBleu, maxPotBleu, 0, quantiteCouleur), 0, 100);
  int jaune = constrain(map(analogRead(pinPotJaune), minPotJaune, maxPotJaune,  0, quantiteCouleur), 0, 100);
  int violet = constrain(map(analogRead(pinPotViolet), minPotViolet, maxPotViolet,  0, quantiteCouleur), 0, 100);
  int gris = constrain(map(analogRead(pinPotGris), minPotGris, maxPotGris,  0, quantiteCouleur), 0, 100);
  int Ingredient1 = constrain(map(analogRead(pinPotIngredient1), minPotIngredient1, maxPotIngredient1, 0, quantiteIngredient), 0, 100);
  int Ingredient2 = constrain(map(analogRead(pinPotIngredient2), minPotIngredient2, maxPotIngredient2, 0, quantiteIngredient), 0, 100);
  int Ingredient3 = constrain(map(analogRead(pinPotIngredient3), minPotIngredient3, maxPotIngredient3, 0, quantiteIngredient), 0, 100);
  int Ingredient4 = constrain(map(analogRead(pinPotIngredient4), minPotIngredient4, maxPotIngredient4, 0, quantiteIngredient), 0, 100);
  int Ingredient5 = constrain(map(analogRead(pinPotIngredient5), minPotIngredient5, maxPotIngredient5, 0, quantiteIngredient), 0, 100);
  int Ingredient6 = constrain(map(analogRead(pinPotIngredient6), minPotIngredient6, maxPotIngredient6, 0, quantiteIngredient), 0, 100);
  int Ingredient7 = constrain(map(analogRead(pinPotIngredient7), minPotIngredient7, maxPotIngredient7, 0, quantiteIngredient), 0, 100);
  
  int RatioRouge = ratio2(rouge, bleu, jaune, violet, gris);
  int RatioBleu = ratio2(bleu, rouge, jaune, violet, gris);
  int RatioJaune = ratio2(jaune, bleu, rouge, violet, gris);
  int RatioViolet = ratio2(violet, bleu, jaune, rouge, gris);
  int RatioGris = ratio2(gris, bleu, jaune, violet, rouge);
  int RatioIngredient1 = ratio3(Ingredient1, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient7);
  int RatioIngredient2 = ratio3(Ingredient2, Ingredient1, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient7);
  int RatioIngredient3 = ratio3(Ingredient3, Ingredient2, Ingredient1, Ingredient4, Ingredient5, Ingredient6, Ingredient7);
  int RatioIngredient4 = ratio3(Ingredient4, Ingredient2, Ingredient3, Ingredient1, Ingredient5, Ingredient6, Ingredient7);
  int RatioIngredient5 = ratio3(Ingredient5, Ingredient2, Ingredient3, Ingredient4, Ingredient1, Ingredient6, Ingredient7);
  int RatioIngredient6 = ratio3(Ingredient6, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient1, Ingredient7);
  int RatioIngredient7 = ratio3(Ingredient7, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient1);
 
  //Bouton de mise en marche des réglages
  boolean etatBoutonMiseEnMarche=digitalRead(boutonMiseEnMarche);
  if(etatBoutonMiseEnMarche == boutonPinEtatOn){
    
    routeRouge = mpapNombreDePasAtourner * RatioRouge;
    routeBleu = mpapNombreDePasAtourner * RatioBleu;
    routeJaune = mpapNombreDePasAtourner * RatioJaune;
    routeViolet = mpapNombreDePasAtourner * RatioViolet;
    routeGris = mpapNombreDePasAtourner * RatioGris;
    routeIngredient1 = mpapNombreDePasAtourner * RatioIngredient1;
    routeIngredient2 = mpapNombreDePasAtourner * RatioIngredient2;
    routeIngredient3 = mpapNombreDePasAtourner * RatioIngredient3;
    routeIngredient4 = mpapNombreDePasAtourner * RatioIngredient4;
    routeIngredient5 = mpapNombreDePasAtourner * RatioIngredient5;
    routeIngredient6 = mpapNombreDePasAtourner * RatioIngredient6;
    routeIngredient7 = mpapNombreDePasAtourner * RatioIngredient7;

    MPAP1.move(routeIngredient1);
    MPAP1.run();
    MPAP2.move(routeIngredient2);
    MPAP2.run();
    MPAP3.move(routeIngredient3);
    MPAP3.run();
    MPAP4.move(routeIngredient4);
    MPAP4.run();
    MPAP5.move(routeIngredient5);
    MPAP5.run();
    MPAP6.move(routeIngredient6);
    MPAP6.run();
    MPAP7.move(routeIngredient7);
    MPAP7.run();
    mpapRouge.move(routeRouge);
    mpapRouge.run();
    mpapBleu.move(routeBleu);
    mpapBleu.run();
    mpapJaune.move(routeJaune);
    mpapJaune.run();
    mpapViolet.move(routeViolet);
    mpapViolet.run();
    mpapGris.move(routeGris);
    mpapGris.run();
  }
  //Bouton d'arrêt d'urgence
  boolean etatBoutonArretDUrgence=digitalRead(boutonArretDUrgence);//variable booléenne du bouton d'arrêt d'urgence
  if(etatBoutonArretDUrgence == boutonPinEtatOn){
    MPAP1.stop();
    MPAP2.stop();
    MPAP3.stop();
    MPAP4.stop();
    MPAP5.stop();
    MPAP6.stop();
    MPAP7.stop();
    mpapRouge.stop();
    mpapBleu.stop();
    mpapJaune.stop();
    mpapViolet.stop();
    mpapGris.stop();
  }
  
  boolean etatBouton=digitalRead(boutonNemaIng1);
  if (etatBouton == boutonPinEtatOn)
  {
    
    MPAP1.move(mpapNombreDePasAtourner);
  }
  MPAP1.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton2=digitalRead(boutonNemaIng2);
  if (etatBouton2 == boutonPinEtatOn)
  {
    MPAP2.move(mpapNombreDePasAtourner);
  }
  MPAP2.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton3 = digitalRead(boutonNemaIng3);
  if (etatBouton3 == boutonPinEtatOn)
  {
    MPAP3.move(mpapNombreDePasAtourner);
  }
  MPAP3.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton4 = digitalRead(boutonNemaIng4);
  if (etatBouton4 == boutonPinEtatOn)
  {
    
    MPAP4.move(mpapNombreDePasAtourner);
  }
  MPAP4.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton5 = digitalRead(boutonNemaIng5);
  if (etatBouton5 == boutonPinEtatOn)
  {
    MPAP5.move(mpapNombreDePasAtourner);
  }
  MPAP5.run();
  // // // // // // // // // // // // // // //
  boolean etatBouton6 = digitalRead(boutonNemaIng6);
  if (etatBouton6 == boutonPinEtatOn)
  {
    MPAP6.move(mpapNombreDePasAtourner);
  }
  MPAP6.run();
  // // // // // // // // // // // // // // //
  boolean etatBouton7 = digitalRead(boutonNemaIng7);
  if (etatBouton7 == boutonPinEtatOn)
  {
    MPAP7.move(mpapNombreDePasAtourner);
  }
  MPAP7.run();
  // // // // // // // // // // // // // // //
  // // // // // // // // // // // // // // //
  boolean etatBouton11 = digitalRead(boutonNemaRouge);
  if (etatBouton11 == boutonPinEtatOn){
    mpapRouge.move(mpapNombreDePasAtourner);
  } 
  mpapRouge.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton12 = digitalRead(boutonNemaBleu);
  if (etatBouton12 == boutonPinEtatOn){
    Serial.println("etatBoutonMiseEnMarche est LOW ");
    mpapBleu.move(mpapNombreDePasAtourner);
  } 
  mpapBleu.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton13 = digitalRead(boutonNemaJaune);
  if (etatBouton13 == boutonPinEtatOn){
    mpapJaune.move(-mpapNombreDePasAtourner);
  } 
  mpapJaune.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton14 = digitalRead(boutonNemaViolet);
  if (etatBouton14 == boutonPinEtatOn){
    mpapViolet.move(mpapNombreDePasAtourner);
  } 
  mpapViolet.run();
  // // // // // // // // // // // // // // // 
  boolean etatBouton15 = digitalRead(boutonNemaGris);
  if (etatBouton15 == boutonPinEtatOn){
    mpapGris.move(mpapNombreDePasAtourner);
  } 
  mpapGris.run();
  
  
  //Bouton d'affichage
  boolean etatBoutonAffichage=digitalRead(boutonPinAffichage);
  if (etatBoutonAffichage == boutonPinEtatOn){
    Serial.println("etatBoutonMiseEnMarche est LOW ");
    Serial.print("Qte couleur:"); Serial.print(quantiteCouleur);  Serial.print(" gouttes |");
    Serial.print("Qte ingredient:");  Serial.print(quantiteIngredient); Serial.print(" ml |");
    Serial.print("rouge:");  Serial.print(ratio2(rouge, bleu, jaune, violet, gris)); Serial.print("% |");
    Serial.print("bleu:");  Serial.print(ratio2(bleu, rouge, jaune, violet, gris)); Serial.print("% |");
    Serial.print("jaune:");  Serial.print(ratio2(jaune, bleu, rouge, violet, gris)); Serial.print("% |");
    Serial.print("violet:");  Serial.print(ratio2(violet, bleu, jaune, rouge, gris)); Serial.print("% |");
    Serial.print("gris:");  Serial.print(ratio2(gris, bleu, jaune, violet, rouge)); Serial.print("% |");
    //////////////////////////////////////////////////////////////////////////////////////
    Serial.print("Ing1:");  Serial.print(ratio3(Ingredient1, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient7)); Serial.print("% |");
    Serial.print("Ing2:");  Serial.print(ratio3(Ingredient2, Ingredient1, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient7)); Serial.print("% |");
    Serial.print("Ing3:");  Serial.print(ratio3(Ingredient3, Ingredient2, Ingredient1, Ingredient4, Ingredient5, Ingredient6, Ingredient7)); Serial.print("% |");
    Serial.print("Ing4:");  Serial.print(ratio3(Ingredient4, Ingredient2, Ingredient3, Ingredient1, Ingredient5, Ingredient6, Ingredient7)); Serial.print("% |");
    Serial.print("Ing5:");  Serial.print(ratio3(Ingredient5, Ingredient2, Ingredient3, Ingredient4, Ingredient1, Ingredient6, Ingredient7)); Serial.print("% |");
    Serial.print("Ing6:");  Serial.print(ratio3(Ingredient6, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient1, Ingredient7)); Serial.print("% |");
    Serial.print("Ing7:");  Serial.print(ratio3(Ingredient7, Ingredient2, Ingredient3, Ingredient4, Ingredient5, Ingredient6, Ingredient1)); Serial.println("%");
    delay(700);
    
  }
}

Cordialement

Comme je n'ai pas ta partie opérative, j'ai testé sans moteurs et sas interrupteurs, en visualisant à l'analyseur pour les sorties et en utilisant un fil dupont pour simuler un bouton. Du coup, c'est facile de mesurer le temps entre deux impulsions et le logiciel donne la fréquence directement. Le mesure ainsi est nettement plus facile.



[quote="enash, post:12, topic:1006209"] Concernant les boutons dédiés à chaque moteur, tant que l'on reste appuyé sur le bouton d'un moteur, celui ci doit continuer de tourner et si on le relâche ils doit cesser de tourner comme pour le code suivant composé seulement de accelstepper: [/quote] Dans les deux cas, le code est le suivant:
 boolean etatBouton=digitalRead(boutonNemaIng1);
  if (etatBouton == boutonPinEtatOn)
  {
    MPAP1.move(mpapNombreDePasAtourner);
  }

Avec ce code, tant que le bouton est appuyé, on lui redemande de faire 100 pas ou 200 pas dans le nouveau programme. Si on relâche le bouton, il lui restera 99 ou 199 pas à faire, ce qui représente tout de même un demi tour ou un tour entier. On ne peut pas avec ce code faire que le moteur s'arrête au relâchement. Cela fonctionne peut être avec 5 pas car au relâchement, 5 pas passent innapperçus.
Ce n'est pas en tout cas ce que tu veux que j'ai observé, mais bien une rotation qui tourne encore un moment. J'ai fait une impulsion courte sur le bouton rouge, et j'ai des impulsions step pendant quelques secondes (j'ai réduit par 10 le nombre de pas à faire pour ne pas avoir à attendre trop longtemps).



Je ne vois pas ce qui pourait le justifier dans le code. Si c'est 2 fois moins vite, il est possible que le A4988 soit en mode demi pas au lieu de pas entier. Mesure la tension qu'il y a sur la broche MS du A4988. On devrait avoir environ 0V.
Autre test: Comme le moteur 4 fonctionne, envoie l'ordre du motuer4 sur le 5 et inversement. On se moque pour l'instant de dir qui sont tous dans le sens direct. Pour cela change pour l'essai

const byte mpapDirPin4 = 28;     // Pour driver MPAP pin pas
const byte mpapStepPin4 = 22;     // Pour driver MPAP pin direction

const byte mpapDirPin5 = 47;     // Pour driver MPAP pin pas
const byte mpapStepPin5 = 45;     // Pour driver MPAP pin direction

en

const byte mpapDirPin4 = 47;     // Pour driver MPAP pin pas
const byte mpapStepPin4 = 22;     // Pour driver MPAP pin direction

const byte mpapDirPin5 = 28;     // Pour driver MPAP pin pas
const byte mpapStepPin5 = 45;     // Pour driver MPAP pin direction

Et voit si c'est le même moteur qui va plus lentement que les autres. Si oui, cela ne vient pas du code, mais du driver.



Pour les boutons, vérifie qu'il y a bien un fil de GND entre l'Arduino et les pistes bleues des breadboards, fil que je ne vois pas sur le schéma du post #1.

Si ce n'est pas le cas, il faudrait les vérifier indépendamment du code. Sans changer la partie opérative, on peut faire un programme dans le genre:

const byte boutonNemaIng1 = 32;
const byte boutonNemaIng2 = 34;
const byte boutonNemaIng3 = 33;
const byte boutonNemaIng4 = 52;
const byte boutonNemaIng5 = 53;
const byte boutonNemaIng6 = 3;
const byte boutonNemaIng7 = 4;

const byte boutonNemaRouge = 35;
const byte boutonNemaBleu = 36;
const byte boutonNemaJaune = 38;
const byte boutonNemaViolet = 49;
const byte boutonNemaGris = 29;

const byte boutonPinAffichage = 12;
const byte boutonMiseEnMarche = 8;
const byte boutonArretDUrgence = 18;

void setup()
{
  pinMode(boutonNemaIng1, INPUT_PULLUP);
  pinMode(boutonNemaIng2, INPUT_PULLUP);
  pinMode(boutonNemaIng3, INPUT_PULLUP);
  pinMode(boutonNemaIng4, INPUT_PULLUP);
  pinMode(boutonNemaIng5, INPUT_PULLUP);
  pinMode(boutonNemaIng6, INPUT_PULLUP);
  pinMode(boutonNemaIng7, INPUT_PULLUP);
  pinMode(boutonNemaRouge, INPUT_PULLUP);
  pinMode(boutonNemaBleu, INPUT_PULLUP);
  pinMode(boutonNemaJaune, INPUT_PULLUP);
  pinMode(boutonNemaViolet, INPUT_PULLUP);
  pinMode(boutonNemaGris, INPUT_PULLUP);

  pinMode(boutonPinAffichage, INPUT_PULLUP);
  pinMode(boutonMiseEnMarche, INPUT_PULLUP);
  pinMode(boutonArretDUrgence, INPUT_PULLUP);

  Serial.begin(115200);
}

void loop(){
  Serial.print(digitalRead(boutonNemaIng1));
  Serial.print(digitalRead(boutonNemaIng2));
  Serial.print(digitalRead(boutonNemaIng3));
  Serial.print(digitalRead(boutonNemaIng4));
  Serial.print(digitalRead(boutonNemaIng5));
  Serial.print(digitalRead(boutonNemaIng6));
  Serial.print(digitalRead(boutonNemaIng7));
  Serial.print(digitalRead(boutonNemaRouge));
  Serial.print(digitalRead(boutonNemaBleu));
  Serial.print(digitalRead(boutonNemaJaune));
  Serial.print(digitalRead(boutonNemaViolet));
  Serial.print(digitalRead(boutonNemaGris));
  Serial.print(digitalRead(boutonPinAffichage));
  Serial.print(digitalRead(boutonMiseEnMarche));
  Serial.print(digitalRead(boutonArretDUrgence));
  Serial.println();
  delay(100);
}

On doit alors voir l'état de tous les boutons (1=HIGH pour le repos, 0 si il y en a un qui est appuyé).
Si les boutons marchent on doit avoir toutes les 100ms s'afficher une ligne qu'avec des 1, et doit apparaître un 0 si on appuis sur un bouton. Si ce n'est pas le cas, il y a un bouton qui ne fonctionne pas.

A priori, ce n'est pas un probl

Bonjour
Quel est ce logiciel utilisé pour mesuré la fréquence ?
Est-ce un analyseur comme celui ci qui a été utilisé ?

Cela échappe à ma compréhension mais en rappuyant sur le bouton du moteur de l'ingrédient 5, il tourne à nouveau normalement sans que je n'ai rien changé au code. D'ailleurs tous les boutons dédiés tournent comme voulu.

En ce qui concerne les fils, je pensais qu'en reliant les breadbords comme ceci, elles allaient partager le même courant 5V de l'arduino (liaisons représentées par les traits bleu et rouge):
image

J'ai relié le troisième 5V et le troisième ground de l'arduino mega aux deuxième bord de la deuxième breadbord comme ceci (liaisons représentées par les traits bleu et rouge):
image
Le système à été améliorer car cette fois j'ai les boutons de mise en marche avant et arrière qui fonctionnent mais les autres boutons ne marchent toujours pas.

Voici le schéma complet malgré la complexité au cas ou avec un seul moteur de représenter car les moteurs sont tous les mêmes et branchés de la même manière avec les drivers:

Voici un zoom sur la partie avec les potentiomètres:

Voici un zoom sur la partie des drivers:

Comment dois je m'y prendre pour arranger les 3 derniers boutons ?

Cordialement

C'est moi ou la partie puissance est alimentée en 5V par la breadboard?
Ce même 5V venant de l'Arduino?

Bonsoir
Ceci est un adaptateur relié à une alimentation 12V:
image
Il s'agit du même adaptateur qui se trouve ici:

Les 12V sont réparties sur les deux bords gauche de chaque breadbord:
image

Voici un zoom pour mieux visualiser:
image

Cordialement

Les breadboards ne sont pas du tout prévues pour faire circuler des courants de plusieurs ampères.
Chaque contact est constitué d'une petites pince qui vient serrer le fil. Autant dire que les points de contacts sont réduits. Il doit y avoir pas mal de chute le long de la ligne.
A minima, il faudrait que la seconde breadboard ne soit pas en cascade derrière la première mais soit raccordée sur l'adaptateur.

Les breadboards ça passe pour faire joujou avec des LEDs mais lorsqu'on commande des organes de puissance, il faut passer à autre chose.

Pour placer un fil à l'intérieur de l'adaptateur, je dois serrer une vis. Dois-je serrer deux fils dans son 12V et deux fils dans son ground le tout relier aux breadbord comme ceci ?:

Par quoi pourrait-je remplacer les breadbords ?

Cordialement

La photo ne représenta pas un analyseur LOGIQUE. Celui que j'utilise et que beaucoup touvent intéressant est celui-ci
C'est d'ailleurs avec ça que j'ai écrit MTstepStepper, les vrais moteurs pas à pas sont venus ensuite, juste pour vérifier. Je conseille ce bidule avec Arduino. C'est presque plus utile qu'un multimètre.

Il manque un fil, ce qui peut expliquer que certains boutons ne fonctionnent pas, et même qu'un moteur tourne au ralenti. Les lignes GND à gauche et à droite d'une même breadboard ne sont pas reliées. Il faut rajouter un fil pour les relier, par exemple:
image

Bonsoir
J'ai essayé de faire fonctionner les boutons défaillants avec le fil branché comme indiqué mais cela n'a pas changé grand chose. Peut être devrais je préciser que le bouton d'arrêt d'urgence fonctionne assez bien, et qu'il est normal que les boutons de mise en marche avant et arrière ne fonctionnent pas toujours sachant que j'ai intégré la bibliothèque MTobject lorsqu'elle était en construction. C'est surtout le bouton d'affichage des ratios et celui de mise en route des moteurs suivant les ratios qui posent problème. J'ai pu me procurer 3 drivers et condensateurs en plus. Je vais voir ce que ça donne lorsque ces derniers sont branchés.
La bibliothèque MTobject a-t-elle été finalisée ou bien est-elle encore en construction ?

Cordialement