2

I'm trying to receive remote information with an IR receiver and this is my code:

#include <IRremote.h>

int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
  delay(100);
}

I tried to upload this to Arduino and it says:

exit status 1
redefinition of 'int RECV_PIN'

How can I fix this?

  • I can see no reason for it unless you didn't install the library properly, or the code you show isn't actually the code you are compiling. – Majenko May 17 '17 at 16:11
  • I compiled your code. There is no compilation error. Probably, library problem. Install it properly. – Hasan Jul 17 '17 at 7:07
2

Apparently the name RECV_PIN is used somewhere else, presumably in IRRemote.h -- although not in any version of it I can find. Anyway, just change the name of RECV_PIN to something which doesn't conflict.

For example:

int MY_RECV_PIN = 11;
IRrecv irrecv(MY_RECV_PIN);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.