Send IR values using infrared emitter led on Arduino

12,576

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

Share:
12,576

Related videos on Youtube

Haitham Sy
Author by

Haitham Sy

Updated on June 04, 2022

Comments

  • Haitham Sy
    Haitham Sy almost 2 years

    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

    • Werner Kvalem Vesterås
      Werner Kvalem Vesterås over 10 years
      What type of IR receiver are you using?
    • Haitham Sy
      Haitham Sy over 10 years
    • Werner Kvalem Vesterås
      Werner Kvalem Vesterås over 10 years
      According to the troubleshooting guide, the LED on pin 13 (the onboard LED) will blink when IR is received. Does this happen?
    • Haitham Sy
      Haitham Sy over 10 years
      @WernerVesterås when i use the receive example alone the light blinks but when combing the two examples together the LED stops blinking
    • praks411
      praks411 over 10 years
      This could hardware problem. Try changing the LED and check if it is the same PWM pin used in the library. You may also want to increase the delay to 100 from 40 as per example.