Bonjour à tous,
Je souhaite adapter le programme que j'utilise sur mon robot ( arduino uno et monster moto shield pour la gestion de 2 moteurs CC) pour le controller via une telecommande infra rouge. Mon but serait de pouvoir appuyer sur la touche 1 pour le faire avance, la touche 2 pour reculer la touche 3 que le moteur de droite et la touche gauche que le moteur de gauche.
Malgré mes très nombreuses tentatives, je ne parviens pas à "croiser les 2 sketchs".
Ce serait sympa que quelqu'un puisse m'apporter son aide et eventuellement m'expliquer comment procéder.
Les 2 sketchs que je souhaite croiser sont ci après.
Merci d'avance!!!
Use the motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
function to get motors going in either CW, CCW, BRAKEVCC, or
BRAKEGND. Use motorOff(int motor) to turn a specific motor off.
The motor variable in each function should be either a 0 or a 1.
pwm in the motorGo function should be a value between 0 and 255.
*/
#define BRAKEVCC 0
#define CW 1
#define CCW 2
#define BRAKEGND 3
#define CS_THRESHOLD 100
/* VNH2SP30 pin definitions
xxx[0] controls '1' outputs
xxx[1] controls '2' outputs */
int inApin[2] = {7, 4}; // INA: Clockwise input
int inBpin[2] = {8, 9}; // INB: Counter-clockwise input
int pwmpin[2] = {5, 6}; // PWM input
int cspin[2] = {2, 3}; // CS: Current sense ANALOG input
int enpin[2] = {0, 1}; // EN: Status of switches output (Analog pin)
int statpin = 13;
void setup()
{
Serial.begin(9600);
pinMode(statpin, OUTPUT);
// Initialize digital pins as outputs
for (int i=0; i<2; i++)
{
pinMode(inApin[i], OUTPUT);
pinMode(inBpin[i], OUTPUT);
pinMode(pwmpin[i], OUTPUT);
}
// Initialize braked
for (int i=0; i<2; i++)
{
digitalWrite(inApin[i], LOW);
digitalWrite(inBpin[i], LOW);
}
// motorGo(0, CW, 1023);
// motorGo(1, CCW, 1023);
}
void loop()
{
motorGo(0, CW, 1023);
motorGo(1, CCW, 1023);
delay(500);
motorGo(0, CCW, 1023);
motorGo(1, CW, 1023);
delay(500);
if ((analogRead(cspin[0]) < CS_THRESHOLD) && (analogRead(cspin[1]) < CS_THRESHOLD))
digitalWrite(statpin, HIGH);
}
void motorOff(int motor)
{
// Initialize braked
for (int i=0; i<2; i++)
{
digitalWrite(inApin[i], LOW);
digitalWrite(inBpin[i], LOW);
}
analogWrite(pwmpin[motor], 0);
}
/* motorGo() will set a motor going in a specific direction
the motor will continue going in that direction, at that speed
until told to do otherwise.
motor: this should be either 0 or 1, will selet which of the two
motors to be controlled
direct: Should be between 0 and 3, with the following result
0: Brake to VCC
1: Clockwise
2: CounterClockwise
3: Brake to GND
pwm: should be a value between ? and 1023, higher the number, the faster
it'll go
*/
void motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
{
if (motor <= 1)
{
if (direct <=4)
{
// Set inA[motor]
if (direct <=1)
digitalWrite(inApin[motor], HIGH);
else
digitalWrite(inApin[motor], LOW);
// Set inB[motor]
if ((direct==0)||(direct==2))
digitalWrite(inBpin[motor], HIGH);
else
digitalWrite(inBpin[motor], LOW);
analogWrite(pwmpin[motor], pwm);
}
}
}
PROGRAMME Telecommande Infra rouge:
*/
#include <IRremote.h>
int broche_reception_ir = 11; // broche 11 utilisée
IRrecv reception_ir(broche_reception_ir); // crée une instance
decode_results decode_ir; // stockage données reçues
void loop()
{
if (reception_ir.decode(&decode_ir))
{
if (decode_ir.value == 0xC1CC8679)
{
// touche 1 –> Robot avance
moteur(250, LOW, 250, LOW);
}
if (decode_ir.value == 0xC1CC46B9)
{
// touche 2 –> Robot recule
moteur(150, LOW, 150, LOW);
}
if (decode_ir.value == 0xC1CCC639)
{
// touche 3 –> Robot tourne à droite
moteur(250, LOW, 150, LOW);
}
if (decode_ir.value == 0xC1CC26D9)
{
// touche 4 –> Robot tourne à gauche
virage_90(HIGH);
moteur(150, LOW, 150, LOW);
}
reception_ir.resume(); // reçoit le prochain code
}
}
hello
il manque le setup dans le 2ème code
Merci de la réponse .
Je ne l'ai volontairement pas mis car je voulais juste faire apparaitre les différentes fonctions de la librairie <IRremote.h>.
En fait pour être plus clair, mon but serait d'intégrer cette librairie et ses différentes fonctions dans mon sketch principal ( celui qui gère les moteurs en automatique) afin de piloter mon robot avec 4 touches de la télécommande (avance, recule, moteur gauche uniquement et moteur droite uniquement).
j'ai regardé un peu
cela va t'aider à intégrer tes fonctions
#include <IRremote.h>
int broche_reception_ir = 11; // broche 11 utilisée
IRrecv reception_ir(broche_reception_ir); // crée une instance
decode_results decode_ir; // stockage données reçues
void setup()
{
Serial.begin(9600);
pinMode(statpin, OUTPUT);
}
void loop()
{
if (reception_ir.decode(&decode_ir))
{
if (decode_ir.value == 0xC1CC8679)
{
// touche 1 -> Robot avance
moteur(250, LOW, 250, LOW);
}
if (decode_ir.value == 0xC1CC46B9)
{
// touche 2 -> Robot recule
moteur(150, LOW, 150, LOW);
}
if (decode_ir.value == 0xC1CCC639)
{
// touche 3 -> Robot tourne à droite
moteur(250, LOW, 150, LOW);
}
if (decode_ir.value == 0xC1CC26D9)
{
// touche 4 -> Robot tourne à gauche
virage_90(HIGH);
moteur(150, LOW, 150, LOW);
}
reception_ir.resume(); // reçoit le prochain code
}
}
En fait mon problème, c'est que je ne parviens pas à modifier mon programme principal en y intégrant les fonctions de librairoe Iremote
ok
je te joint ton code
il se compile.
mais peut être qu'il ne fonctionne pas. c'est toi qui as la partie hard
donc tu fais tes tests et tu essaies de comprendre ce qui ne va pas (si ça ne tourne pas.)
je n'irai pas beaucoup plus loin
#include <IRremote.h>
/*
Use the motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
function to get motors going in either CW, CCW, BRAKEVCC, or
BRAKEGND. Use motorOff(int motor) to turn a specific motor off.
The motor variable in each function should be either a 0 or a 1.
pwm in the motorGo function should be a value between 0 and 255.
*/
#define BRAKEVCC 0
#define CW 1
#define CCW 2
#define BRAKEGND 3
#define CS_THRESHOLD 100
/* VNH2SP30 pin definitions
xxx[0] controls '1' outputs
xxx[1] controls '2' outputs */
int inApin[2] = {7, 4}; // INA: Clockwise input
int inBpin[2] = {8, 9}; // INB: Counter-clockwise input
int pwmpin[2] = {5, 6}; // PWM input
int cspin[2] = {2, 3}; // CS: Current sense ANALOG input
int enpin[2] = {0, 1}; // EN: Status of switches output (Analog pin)#include <IRremote.h>
int broche_reception_ir = 11; // broche 11 utilisée
IRrecv reception_ir(broche_reception_ir); // crée une instance
decode_results decode_ir; // stockage données reçues
int statpin = 13;
void setup()
{
Serial.begin(9600);
pinMode(statpin, OUTPUT);
// Initialize digital pins as outputs
for (int i=0; i<2; i++)
{
pinMode(inApin[i], OUTPUT);
pinMode(inBpin[i], OUTPUT);
pinMode(pwmpin[i], OUTPUT);
}
// Initialize braked
for (int i=0; i<2; i++)
{
digitalWrite(inApin[i], LOW);
digitalWrite(inBpin[i], LOW);
}
}
void loop()
{ if ((analogRead(cspin[0]) < CS_THRESHOLD) && (analogRead(cspin[1]) < CS_THRESHOLD))
digitalWrite(statpin, HIGH);
if (reception_ir.decode(&decode_ir))
{
if (decode_ir.value == 0xC1CC8679)
{
// touche 1 -> Robot avance
motorGo(0, CW, 1023);// moteur 1,clockwise,pwm
motorGo(1, CW, 1023);// moteur 2,clockwise,pwm
}
if (decode_ir.value == 0xC1CC46B9)
{
// touche 2 -> Robot recule
motorGo(0, CCW, 1023);// moteur 1,anticlockwise,pwm
motorGo(1, CCW, 1023);// moteur 2,anticlockwise,pwm
}
if (decode_ir.value == 0xC1CCC639)
{
// touche 3 -> Robot tourne à droite
motorGo(0, CW, 1023);// moteur 1,clockwise,pwm
motorGo(1, CCW, 1023);// moteur 2,anticlockwise,pwm
}
if (decode_ir.value == 0xC1CC26D9)
{
// touche 4 -> Robot tourne à gauche
motorGo(0, CCW, 1023);// moteur 1,anticlockwise,pwm
motorGo(1, CW, 1023);// moteur 2,clockwise,pwm
}
reception_ir.resume(); // reçoit le prochain code
}
}
/* motorGo() will set a motor going in a specific direction
the motor will continue going in that direction, at that speed
until told to do otherwise.
motor: this should be either 0 or 1, will selet which of the two
motors to be controlled
direct: Should be between 0 and 3, with the following result
0: Brake to VCC
1: Clockwise
2: CounterClockwise
3: Brake to GND
pwm: should be a value between ? and 1023, higher the number, the faster
it'll go
*/
void motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
{
if (motor <= 1)
{
if (direct <=4)
{
// Set inA[motor]
if (direct <=1)
digitalWrite(inApin[motor], HIGH);
else
digitalWrite(inApin[motor], LOW);
// Set inB[motor]
if ((direct==0)||(direct==2))
digitalWrite(inBpin[motor], HIGH);
else
digitalWrite(inBpin[motor], LOW);
analogWrite(pwmpin[motor], pwm);
}
}
}
void motorOff(int motor)
{
// Initialize braked
for (int i=0; i<2; i++)
{
digitalWrite(inApin[i], LOW);
digitalWrite(inBpin[i], LOW);
}
analogWrite(pwmpin[motor], 0);
}
Merci beaucoup!!!
Je vais essayer ça ce soir et te tiens au courant.
Autrement je n'ai pas chômé depuis mon précedent poste, j'ai ré essayé de pondre un sketch faisant plus ou moins ce que je voulais et ça à l'air d'être bon, il se compile!!!
Peux tu jeter un oeil et me dire ce que tu en penses (améliorations, incohérence etc...)
#include <IRremote.h>
int broche_reception_ir = 11; // broche 11 utilisée pour le capteur IR
int InA1[2]= {7,4}; // Pins pour activer les 2 moteurs en marche avant
int InB1[2]= {8,9}; // Pins pour activer les 2 moteurs en sens inverse
int InC1= 7; // active le moteur de droite uniquement en marche avant
int InC2= 4; // active le moteur de gauche uniquement en marche avant
int InD1= 8; // active le moteur de droite uniquement en marche arriere
int InD2= 9; // active le moteur de gauche uniquement en marche arriere
int PWM1[2]= {5,6}; //Pins pour gérer la puissance des 2 moteurs
int PWM1_val = 10; //(25% = 64; 50% = 127; 75% = 191; 100% = 255) //Ajout de la fonction PWM en pourcentage
IRrecv reception_ir(broche_reception_ir); // Active la reception IR
decode_results decode_ir; // stockage données reçues
void setup() {
Serial.begin(9600);
pinMode(broche_reception_ir, OUTPUT);
pinMode(InA1[2], OUTPUT); // Active les 2 moteurs en avant Robot avance
pinMode(InB1[2], OUTPUT); // Active les 2 moteurs en arriere Robot recule
pinMode(InC1, OUTPUT); // Active le moteur de droite, Robot tourne a gauche en marche avant
pinMode(InC2, OUTPUT); // Active le moteur de gauche, Robot tourne a droite en marche avant
pinMode(InD1, OUTPUT); // Active le moteur de droite, Robot tourne a gauche en marche arriere
pinMode(InD2, OUTPUT); // Active le moteur de gauche, Robot tourne a droite en marche arriere
pinMode(PWM1[2], OUTPUT); // Gere la vitesse des moteurs
}
void loop()
{
if (reception_ir.decode(&decode_ir))
{
if (decode_ir.value == 0xC1CC8679)// touche 1 -> Robot avance
{
digitalWrite(InA1[2], HIGH);
analogWrite(PWM1[2], PWM1_val);
}
if (decode_ir.value == 0xC1CC46B9)// touche 2 -> Robot recule
{
digitalWrite(InB1[2], HIGH);
analogWrite(PWM1[2], PWM1_val);
}
if (decode_ir.value == 0xC1CCC639)// touche 3 -> Robot tourne à droite en marche avant
{
digitalWrite(InC2, HIGH);
analogWrite(PWM1[2], PWM1_val);
}
if (decode_ir.value == 0xC1CCC639)// touche 4 -> Robot tourne à gauche en marche avant
{
digitalWrite(InC1, HIGH);
analogWrite(PWM1[2], PWM1_val);
}
if (decode_ir.value == 0xC1CCC639)// touche 5 -> Robot tourne à droite en marche arriere
{
digitalWrite(InD2, HIGH);
analogWrite(PWM1[2], PWM1_val);
}
if (decode_ir.value == 0xC1CCC639)// touche 6 -> Robot tourne à gauche en marche arriere
{
digitalWrite(InD1, HIGH);
analogWrite(PWM1[2], PWM1_val);
}
}
reception_ir.resume(); // reçoit le prochain code
}
J'ai mis une valeur PWM assez basse car j'ai récupéré 2 vieilles visseuses et leurs batteries pour la propulsion et quand les moteurs tournent à fond, ça fait un sacré boucan
ca fonctionne ou pas ?
Je vais essayer ça ce soir et te tiens au jus.
Merci
Bonjour,
Ni le premier code ni le second ne fonctionne.
Après les avoir injecté, j'appuie sur les touches de la telecommande dediées aux mouvements des moteurs et rien ne se passe.
Je précise que la connexion IR fonctionne parfaitement.
Peut être un oubli dans le sketch mais après avoir regardé de plus prêt je n'ai rien trouver qui puisse expliquer ce problème.
Si quelqu'un avait le temps de se pencher dessus, ce serait cool.
Merci.
ajoute des serial.Print, et ouvre ton moniteur à la bonne vitesse
le programme de télécommande fonctionne t'il seul?
Salut dfgh, oui il fonctionne je viens de le re tester lorsque j'appuie sur une touche de la telecommande et que j'ouvre le moniteur serie, j'ai bien le code hexa qui s'affiche
testes ça avec le moniteur en 9600
ton code moteur semble bizarre dans le test de "direct"
et tu n'appelle pas "motor off"
#include <IRremote.h>
/*
Use the motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
function to get motors going in either CW, CCW, BRAKEVCC, or
BRAKEGND. Use motorOff(int motor) to turn a specific motor off.
The motor variable in each function should be either a 0 or a 1.
pwm in the motorGo function should be a value between 0 and 255.
*/
#define BRAKEVCC 0
#define CW 1
#define CCW 2
#define BRAKEGND 3
#define CS_THRESHOLD 100
/* VNH2SP30 pin definitions
xxx[0] controls '1' outputs
xxx[1] controls '2' outputs */
int inApin[2] = {7, 4}; // INA: Clockwise input
int inBpin[2] = {8, 9}; // INB: Counter-clockwise input
int pwmpin[2] = {5, 6}; // PWM input
int cspin[2] = {2, 3}; // CS: Current sense ANALOG input
int enpin[2] = {0, 1}; // EN: Status of switches output (Analog pin)#include <IRremote.h>
int broche_reception_ir = 11; // broche 11 utilisée
IRrecv reception_ir(broche_reception_ir); // crée une instance
decode_results decode_ir; // stockage données reçues
int statpin = 13;
void setup()
{
Serial.begin(9600);
pinMode(statpin, OUTPUT);
// Initialize digital pins as outputs
for (int i=0; i<2; i++)
{
pinMode(inApin[i], OUTPUT);
pinMode(inBpin[i], OUTPUT);
pinMode(pwmpin[i], OUTPUT);
}
// Initialize braked
for (int i=0; i<2; i++)
{
digitalWrite(inApin[i], LOW);
digitalWrite(inBpin[i], LOW);
}
}
void loop()
{ if ((analogRead(cspin[0]) < CS_THRESHOLD) && (analogRead(cspin[1]) < CS_THRESHOLD))
digitalWrite(statpin, HIGH);
if (reception_ir.decode(&decode_ir))
{
if (decode_ir.value == 0xC1CC8679)
{
// touche 1 -> Robot avance
Serial.print("Robot avance ");
motorGo(0, CW, 1023);// moteur 1,clockwise,pwm
motorGo(1, CW, 1023);// moteur 2,clockwise,pwm
}
if (decode_ir.value == 0xC1CC46B9)
{
// touche 2 -> Robot recule
Serial.print("Robot recule ");
motorGo(0, CCW, 1023);// moteur 1,anticlockwise,pwm
motorGo(1, CCW, 1023);// moteur 2,anticlockwise,pwm
}
if (decode_ir.value == 0xC1CCC639)
{
// touche 3 -> Robot tourne à droite
Serial.print("Robot tourne à droite ");
motorGo(0, CW, 1023);// moteur 1,clockwise,pwm
motorGo(1, CCW, 1023);// moteur 2,anticlockwise,pwm
}
if (decode_ir.value == 0xC1CC26D9)
{
// touche 4 -> Robot tourne à gauche
Serial.print("Robot tourne à gauche ");
motorGo(0, CCW, 1023);// moteur 1,anticlockwise,pwm
motorGo(1, CW, 1023);// moteur 2,clockwise,pwm
}
reception_ir.resume(); // reçoit le prochain code
}
}
/* motorGo() will set a motor going in a specific direction
the motor will continue going in that direction, at that speed
until told to do otherwise.
motor: this should be either 0 or 1, will selet which of the two
motors to be controlled
direct: Should be between 0 and 3, with the following result
0: Brake to VCC
1: Clockwise
2: CounterClockwise
3: Brake to GND
pwm: should be a value between ? and 1023, higher the number, the faster
it'll go
*/
void motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
{
if (motor <= 1)
{Serial.print("motor <=1 ");
if (direct <=4)
{Serial.print("direct <=4");
// Set inA[motor]
if (direct <=1){digitalWrite(inApin[motor], HIGH);Serial.print("direct <=1");}
else{digitalWrite(inApin[motor], LOW);}
// Set inB[motor]
if ((direct==0)||(direct==2)){digitalWrite(inBpin[motor], HIGH);Serial.print("direct ==0 ou ==2");}
else{digitalWrite(inBpin[motor], LOW);}
analogWrite(pwmpin[motor], pwm);
}
}
}
void motorOff(int motor)
{
// Initialize braked
for (int i=0; i<2; i++)
{
digitalWrite(inApin[i], LOW);
digitalWrite(inBpin[i], LOW);
}
analogWrite(pwmpin[motor], 0);
}
Slt, toujours rien aucune réaction des moteurs et rien ne s'affiche dans le moniteur série. J'ai réessayé le programme sans les commandes IR et celui fonctionne parfaitement en auto
le meme prg
en bébut de Loop, j'ai rajouté une variable :
retour_lecture=0xC1CC8679;
et j'ai forcé la reconnaissance de la reception de la télécommande pour cette valeur:
if (retour_lecture==0xC1CC8679)
ouvres ton moniteur et regardes
#include <IRremote.h>
/*
Use the motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
function to get motors going in either CW, CCW, BRAKEVCC, or
BRAKEGND. Use motorOff(int motor) to turn a specific motor off.
The motor variable in each function should be either a 0 or a 1.
pwm in the motorGo function should be a value between 0 and 255.
*/
#define BRAKEVCC 0
#define CW 1
#define CCW 2
#define BRAKEGND 3
#define CS_THRESHOLD 100
/* VNH2SP30 pin definitions
xxx[0] controls '1' outputs
xxx[1] controls '2' outputs */
int inApin[2] = {7, 4}; // INA: Clockwise input
int inBpin[2] = {8, 9}; // INB: Counter-clockwise input
int pwmpin[2] = {5, 6}; // PWM input
int cspin[2] = {2, 3}; // CS: Current sense ANALOG input
int enpin[2] = {0, 1}; // EN: Status of switches output (Analog pin)#include <IRremote.h>
int broche_reception_ir = 11; // broche 11 utilisée
IRrecv reception_ir(broche_reception_ir); // crée une instance
decode_results decode_ir; // stockage données reçues
int statpin = 13;
unsigned long retour_lecture=0;
void setup()
{
Serial.begin(9600);
pinMode(statpin, OUTPUT);
// Initialize digital pins as outputs
for (int i=0; i<2; i++)
{
pinMode(inApin[i], OUTPUT);
pinMode(inBpin[i], OUTPUT);
pinMode(pwmpin[i], OUTPUT);
}
// Initialize braked
for (int i=0; i<2; i++)
{
digitalWrite(inApin[i], LOW);
digitalWrite(inBpin[i], LOW);
}
}
void loop()
{ if ((analogRead(cspin[0]) < CS_THRESHOLD) && (analogRead(cspin[1]) < CS_THRESHOLD))
digitalWrite(statpin, HIGH);
delay(1000);
Serial.println("");
Serial.println("attente ");
//if (reception_ir.decode(&decode_ir))
retour_lecture=0xC1CC8679;
{
//if (decode_ir.value == 0xC1CC8679)
if (retour_lecture==0xC1CC8679)
{
// touche 1 -> Robot avance
Serial.print("Robot avance ");
motorGo(0, CW, 1023);// moteur 1,clockwise,pwm
motorGo(1, CW, 1023);// moteur 2,clockwise,pwm
}
if (decode_ir.value == 0xC1CC46B9)
{
// touche 2 -> Robot recule
Serial.print("Robot recule ");
motorGo(0, CCW, 1023);// moteur 1,anticlockwise,pwm
motorGo(1, CCW, 1023);// moteur 2,anticlockwise,pwm
}
if (decode_ir.value == 0xC1CCC639)
{
// touche 3 -> Robot tourne à droite
Serial.print("Robot tourne à droite ");
motorGo(0, CW, 1023);// moteur 1,clockwise,pwm
motorGo(1, CCW, 1023);// moteur 2,anticlockwise,pwm
}
if (decode_ir.value == 0xC1CC26D9)
{
// touche 4 -> Robot tourne à gauche
Serial.print("Robot tourne à gauche ");
motorGo(0, CCW, 1023);// moteur 1,anticlockwise,pwm
motorGo(1, CW, 1023);// moteur 2,clockwise,pwm
}
reception_ir.resume(); // reçoit le prochain code
}
}
/* motorGo() will set a motor going in a specific direction
the motor will continue going in that direction, at that speed
until told to do otherwise.
motor: this should be either 0 or 1, will selet which of the two
motors to be controlled
direct: Should be between 0 and 3, with the following result
0: Brake to VCC
1: Clockwise
2: CounterClockwise
3: Brake to GND
pwm: should be a value between ? and 1023, higher the number, the faster
it'll go
*/
void motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
{ Serial.print(" motor =");Serial.print(motor);
Serial.print(" direct =");Serial.print(direct);
Serial.print(" pwm =");Serial.println(pwm);
if (motor <= 1)
{Serial.print(" motor <=1 ");
if (direct <=4)
{Serial.print(" direct <=4");
// Set inA[motor]
if (direct <=1){digitalWrite(inApin[motor], HIGH);Serial.println(" direct <=1");}
else{digitalWrite(inApin[motor], LOW);}
// Set inB[motor]
if ((direct==0)||(direct==2)){digitalWrite(inBpin[motor], HIGH);Serial.println(" direct ==0 ou ==2");}
else{digitalWrite(inBpin[motor], LOW);}
analogWrite(pwmpin[motor], pwm);
}
}
}
/*
Use the motorGo(uint8_t motor, uint8_t direct, uint8_t pwm)
function to get motors going in either CW, CCW, BRAKEVCC, or
BRAKEGND. Use motorOff(int motor) to turn a specific motor off.
The motor variable in each function should be either a 0 or a 1.
pwm in the motorGo function should be a value between 0 and 255.
*/
void motorOff(int motor)
{
// Initialize braked
for (int i=0; i<2; i++)
{
digitalWrite(inApin[i], LOW);
digitalWrite(inBpin[i], LOW);
}
analogWrite(pwmpin[motor], 0);
}
Cette fois ci dans le moniteur série "en attente" s'affiche en boucle avec la led sur l'arduino qui n'arrete pas de clignoter
ci dessous un extrait de ce qui s'affiche dans le moniteur série au cas ou:
attente
Robot avance motor =0 direct =1 pwm =255
motor <=1 direct <=4 direct <=1
motor =1 direct =1 pwm =255
motor <=1 direct <=4 direct <=1
attente
Robot avance motor =0 direct =1 pwm =255
motor <=1 direct <=4 direct <=1
motor =1 direct =1 pwm =255
motor <=1 direct <=4 direct <=1
attente
Robot avance motor =0 direct =1 pwm =255
motor <=1 direct <=4 direct <=1
motor =1 direct =1 pwm =255
motor <=1 direct <=4 direct <=1
attente
Robot avance motor =0 direct =1 pwm =255
motor <=1 direct <=4 direct <=1
motor =1 direct =1 pwm =255
motor <=1 direct <=4 direct <=1
attente
Robot avance motor =0 direct =1 pwm =255
motor <=1 direct <=4 direct <=1
motor =1 direct =1 pwm =255
motor <=1 direct <=4 direct <=1
attente
Robot avance motor =0 direct =1 pwm =255
motor <=1 direct <=4 direct <=1
motor =1 direct =1 pwm =255
motor <=1 direct <=4 direct <=1