Go Down

Topic: IRremote and AdaFruit Motor shield doesnt work together! (Read 114 times) previous topic - next topic

GhostMustang

when I gave "ileri" command just front right and front left wheels are running. nothing happening to left wheels. what is the problem?
there is code:

#include <AFMotor.h>
#include <IRremote.h>

int RECV_PIN = 2;
decode_results results;
IRrecv irrecv(RECV_PIN);
#define ileri 0xFF18E7

AF_DCMotor sagarka(3,MOTOR34_64KHZ);
AF_DCMotor solarka(2,MOTOR12_64KHZ);
AF_DCMotor sagon(4,MOTOR34_64KHZ);
AF_DCMotor solon(1,MOTOR12_64KHZ);

void setup() {
  Serial.begin(9600);
  sagon.setSpeed(150);
  sagarka.setSpeed(150);
  solon.setSpeed(150);
  solarka.setSpeed(150);
  irrecv.enableIRIn();
}

void loop() {
  if(irrecv.decode(&results)){
   Serial.println(results.value,HEX);
   if(results.value == ileri){
    sagon.run(FORWARD);
    sagarka.run(FORWARD);
    solon.run(FORWARD);
    solarka.run(FORWARD);
    delay(1000);
    sagon.run(RELEASE);
    sagarka.run(RELEASE);
    solon.run(RELEASE);
    solarka.run(RELEASE);
  }
   irrecv.resume();
  }
}


wildbill

Can you drive all the motors if you drop the IR component (and its code)?

If so, I suspect that you have a pin conflict. From your code, it looks like you could pick another on for the IR. Figure out which Arduino pins are using from the motor driver and attach the IR device to one not in use.

GhostMustang

Yes, all motors work without IR. And this shield is not use pin 2 and 13, so I m using pin2 for IR

Go Up