Hello,
I'm just retrying other things to solve my pb but I stille have the same issue.
I've tried to simplify the code in order to determine where the pb is.
#include <VirtualWire.h>
//declaration des pins du controleur de moteurs
#define out_A_PWM 3
#define out_A_IN2 2
#define out_A_IN1 4
#define out_STBY 5
#define out_B_PWM 6
#define out_B_IN2 7
#define out_B_IN1 8
int ordrePrecedent = 0;
int ordre = 0;
void setup()
{
//pins configuration
pinMode(out_STBY,OUTPUT);
pinMode(out_A_PWM,OUTPUT);
pinMode(out_A_IN1,OUTPUT);
pinMode(out_A_IN2,OUTPUT);
pinMode(out_B_PWM,OUTPUT);
pinMode(out_B_IN1,OUTPUT);
pinMode(out_B_IN2,OUTPUT);
vw_setup(2400); // Bits per sec
vw_set_rx_pin(9);
vw_rx_start(); // Start the receiver PLL running
analogWrite (out_A_PWM, 80);//set motors speed
analogWrite (out_B_PWM, 80);
Serial.begin(9600);
Serial.println("setup");
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
// PB: while digitalWrite(out_STBY,HIGH), no reception possible.
// out_STBY must be set to LOW in order to get new message, so I can't have a continuous move...
if (vw_get_message(buf, &buflen)) // Non-blocking
{
int i;
// Message with a good checksum received, dump HEX
Serial.print("Got: ");
for (i = 0; i < buflen; i++)
{
Serial.println(buf[i]);
ordre = buf[i];
}
if(ordre!=ordrePrecedent){
switch (ordre) {
case 'A':
avancer();
break;
case 'B':
reculer();
break;
case 'C':
tournerDroite();
break;
case 'D':
tournerGauche();
break;
case 'E':
//mode = 1;
break;
case 'F':
//mode = 0;
break;
case 'S':
stopper();
break;
}
ordrePrecedent=ordre;
}
}
}
void avancer()
{
digitalWrite(out_STBY,HIGH);
digitalWrite(out_A_IN2, LOW);
digitalWrite(out_A_IN1, HIGH);
digitalWrite(out_B_IN2, LOW);
digitalWrite(out_B_IN1, HIGH);
}
void reculer()
{
digitalWrite(out_STBY,HIGH);
digitalWrite(out_A_IN2, HIGH);
digitalWrite(out_A_IN1, LOW);
digitalWrite(out_B_IN2, HIGH);
digitalWrite(out_B_IN1, LOW);
}
void stopper()
{
digitalWrite(out_STBY,LOW);
}
void tournerGauche()
{
digitalWrite(out_STBY,HIGH);
digitalWrite(out_A_IN2, HIGH);
digitalWrite(out_A_IN1, LOW);
digitalWrite(out_B_IN2, LOW);
digitalWrite(out_B_IN1, HIGH);
}
void tournerDroite()
{
digitalWrite(out_STBY,HIGH);
digitalWrite(out_A_IN2, LOW);
digitalWrite(out_A_IN1, HIGH);
digitalWrite(out_B_IN2, HIGH);
digitalWrite(out_B_IN1, LOW);
}
I know what the pb is but don't know how to fix it. While digitalWrite(out_STBY,HIGH), no reception possible.
out_STBY must be set to LOW in order to get new message, so I can't have a continuous move. Does someone use this motor driver with vitualWire ?
Why out_STBY=HIGH is a prb to receive datas ?
MadProf