mcjohn113:
Hey guys,
I am trying to get motor controlled using IR receiver. The problem I have right now is that the motor does not run in the current program but works fine when I am not using the IR receiver. I am guessing its some programming issue rather than the hardware.#include <AFMotor.h>
#include <IRremote.h>
AF_DCMotor motor(2, MOTOR12_2KHZ);
int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
Serial.begin(9600);
motor.setSpeed(250);
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&results))
{
Serial.print(results.value, DEC);
if(results.value == 1637892797)
{
Serial.print("tock");
motor.run(FORWARD);
delay(1000);
}
else if(results.value == 1637925437)
{
motor.run(RELEASE);
delay(5000);
}
irrecv.resume();
}
}
Thanks a lot, DJ
I have the same problem, and I was able to solve it by just editing the header file IRremoteInt.h by uncommenting the timer I wanted to use and commented the default timer.