Arduino Forum

Using Arduino => Motors, Mechanics, Power and CNC => Topic started by: GhostMustang on Jul 15, 2019, 11:01 pm

Title: IRremote and AdaFruit Motor shield doesnt work together!
Post by: GhostMustang on Jul 15, 2019, 11:01 pm
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();
  }
}

(https://cvws.icloud-content.com/B/AaUlRgx87tLxiLWHhAPcRirhcG5WAWv1XkcndaA5BnLkgQDgWO1JshZz/IMG_6504.JPG?o=AgfmIWN4MDzBZJKs7Iq9MekbDginzN_AvtxxwsW6QuSn&v=1&x=3&a=CAog1xMJf8KyY7ji4176Z9N-dTvyJQc_TER9kLOTiHWkB6oSHRDPvLy7vy0Y77Pzu78tIgEAUgThcG5WWgRJshZz&e=1563225283&k=kjYbu8AFKGuEZMj5B5YubA&fl=&r=96c206b9-c9be-4ad3-b636-f5ccfa8087ec-1&ckc=com.apple.clouddocs&ckz=com.apple.CloudDocs&p=49&s=TI4t4W1KVjqWkl_jmToCJOkEiJU&cd=i)
Title: Re: IRremote and AdaFruit Motor shield doesnt work together!
Post by: wildbill on Jul 15, 2019, 11:16 pm
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.
Title: Re: IRremote and AdaFruit Motor shield doesnt work together!
Post by: GhostMustang on Jul 15, 2019, 11:23 pm
Yes, all motors work without IR. And this shield is not use pin 2 and 13, so I m using pin2 for IR