Send IR values using infrared emitter led on Arduino

Haitham Sy picture Haitham Sy · Sep 24, 2013 · Viewed 12.3k times · Source

i have Arduino Mega and an IR Emitting LED and i want to send data "Hex Data" that i choose using this LED and i have tried the IRRemote Library and i have successfully used the IRrecv class, but when using IRsend i didn't get any signal and have tried to look at the led through the mobile camera
the IR Emitter Pin is PWM 3 and have connected it to 3.3V once and to 5V once

#include <IRremote.h>

IRsend irsend;

void setup()
{
  Serial.begin(9600);
}

void loop() {
  if (Serial.read() != -1) {
    for (int i = 0; i < 3; i++) {
      irsend.sendSony(0xa90, 12); // Sony TV power code
      delay(40);
    }
  }
}

and for the receiver:

#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
  }
}

any help is appreciated :) Hiso

Answer

Yaser Jaradeh picture Yaser Jaradeh · Sep 27, 2013

i Have looked at the IRRemote.cpp library you refereed to and in the header file you can see that each Arduino board have a unique PWM pin that is used to transmit infrared data so use PWM 9 it's assured to work on Arduino Mega