problem whith DRI009

0 12297 Easy

HI, I'm triing to use DRI009 quad motor  driver in my projrect, but  I have some problems: only two motors run . Probably  DRI009 isn't compatible whit IR  sensors and relative librayry <IRremote.h>.
 this is a subset of my sketch : 

CODE
#include <IRremote.h>
#define modello 1080
int RECV_PIN = 9;

IRrecv irrecv(RECV_PIN);

decode_results results;


//run only motor 3 & 4
/*
#include <IRremote.h>
#define modello 1080
int relay = 10;
int RECV_PIN = 9;

IRrecv irrecv(RECV_PIN);

decode_results results;
*/

bool sw_VAavanti = false;
bool sw_avvio = false;

const int E1 = 3; ////<Motor1 Speed
const int M1S = 4; ////<Motor1 Direction

const int E3 = 5; ////<Motor3 Speed
const int M3S = 8; ////<Motor3 Direction

const int E2 = 11;////<Motor2 Speed
const int M2D = 12;////<Motor2 Direction

const int E4 = 6; ////<Motor4 Speed
const int M4D = 7; ////<Motor4 Direction

void M1S_advance(char Speed) ////<Motor1 Advance
{
  digitalWrite(M1S, LOW);
  analogWrite(E1, Speed);
}
void M3S_advance(char Speed) ////<Motor3 Advance
{
  digitalWrite(M3S, LOW);
  analogWrite(E3, Speed);
}
void M2D_advance(char Speed) ////<Motor2 Advance
{
  digitalWrite(M2D, LOW);
  analogWrite(E2, Speed);
}
void M4D_advance(char Speed) ////<Motor4 Advance
{
  digitalWrite(M4D, LOW);
  analogWrite(E4, Speed);
}

void M1S_back(char Speed) ////<Motor1 Back off
{
  digitalWrite(M1S, HIGH);
  analogWrite(E1, Speed);
}
void M3S_back(char Speed) ////<Motor3 Back off
{
  digitalWrite(M3S, HIGH);
  analogWrite(E3, Speed);
}
void M2D_back(char Speed) ////<Motor2 Back off
{
  digitalWrite(M2D, HIGH);
  analogWrite(E2, Speed);
}
void M4D_back(char Speed) ////<Motor4 Back off
{
  digitalWrite(M4D, HIGH);
  analogWrite(E4, Speed);
}

void setup(){
  irrecv.enableIRIn(); // whitout this instruction, 
                       //   it run all correct

/*
  irrecv.enableIRIn(); // Start the receiver
 pinMode( relay, OUTPUT );
*/   
  for(int p=3;p<9;p++){
    pinMode(p,OUTPUT);
  }
  for(int p=11;p<13;p++){
    pinMode(p,OUTPUT);
  }


}


void loop() {
  if (irrecv.decode(&results)) {

    irrecv.resume(); // Receive the next value
    if (results.value != 0xFFFFFFFF) {
    }}
//  avvio();
////  if (sw_avvio) {
if (!sw_VAavanti){

M1S_advance(250);
M3S_advance(250);
M2D_advance(250);
M4D_advance(250);
  
    sw_VAavanti=true;
}
////  }
} 
/*
void avvio() {
  if (irrecv.decode(&results)) {

    irrecv.resume(); // Receive the next value
    if (results.value != 0xFFFFFFFF) {

      if (sw_avvio) {
        stop();
        digitalWrite( relay, LOW);


//        resetSW();
        sw_avvio = false;
      }
      else {
        sw_avvio = true;

        digitalWrite( relay, HIGH);


      }
    }
  }
}

*/
void stop(){
  
M1S_advance(0);
M3S_advance(0);
M2D_advance(0);
M4D_advance(0);

M1S_back(0);
M3S_back(0);
M2D_back(0);
M4D_back(0);

}

 there are somne solution to my problem? 
thank you in advance

danilo.rosso.it@gmail.com
 

License
All Rights
Reserved
licensBg
0