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