Please find my error

the project is a remote controlled motor controlled by infra-red tv controller
i have been on this problem for a while now
i have no idea why when the if statment is meet meaning the ir sensor sees the value 16825533, the serial monitor gets “power” but the motor doesnt go forward
any suggestions would be great :slight_smile:
thanks

paul

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

int RECV_PIN = 14;
int led = 12;
IRrecv irrecv(RECV_PIN);
decode_results results;
AF_DCMotor motor(2);

void setup()
{
  motor.setSpeed(200);
  motor.run (RELEASE);
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, DEC);
    
    irrecv.resume(); // Receive the next value
  }
  
  if ( results.value == 16825533) {
  Serial.println ("Power");
  motor.run(FORWARD);
  delay (1000);

  }
  
  
  
  
  
  }
  if ( results.value == 16825533) {

Literals are interpreted as ints, unless you define otherwise. There is no way that value is an int. Stick UL on the end of the literal, to tell the compiler to interpret the value differently.

"irrecv.resume(); // Receive the next value" belongs after you decode

Pbkey:
i have no idea why when the if statment is meet meaning the ir sensor sees the value 16825533, the serial monitor gets "power" but the motor doesnt go forward

It is safe to assume that motor.run(FORWARD) is being executed and then nothing else is happening for about a second. If the motor doesn't actually run then motor.run() is not having the effect you intend. Perhaps there's a problem with the hardware used to power and drive the motor, or perhaps the AFMotor library is not configured correctly, or is not appropriate for this motor, or has a bug in it, or has a conflict with the IRremote library. Do they both use hardware timers? If so, which ones?

Suggestions:

  1. test your logic first without using the motor. (use the onboard led on pin 13 to debug the code first)
  2. Familiarise yourself with all of the examples provided with the IRremote library and you will be able to answer some of the questions you asked.
  3. In addition to the previous responses, the way your code is written, you will be turning on the motor every second forever (or until you receive a different code) after receiving the code (16825533) once via IR.