Irsend.sendNEC doesn't affect IR LED

Hi!

This is one of my first Arduino projects.
A simple idea when the controller emulates a remote to control a beamer using the IRremote library.
The circuit consists of an Arduino micro, an IR LED and a 330 ohm resistor.
The problem is that the irsend.sendNEC command does not affect the IR LED at all.
The LED works fine if you just turn it on with the digitalWrite command. The code it is supposed to send I have got by decoding my remote using the same tutorial I used for creating a sketch for sending the code (link Using IR Remote Controls with Arduino | DroneBot Workshop). The sketch for decoding recognizes the remote code as a code from the NEC protocol. But even if there is something wrong with the code, the LED should in any case show some activity, but this does not happen.
Here is the sketch, which simply sends a signal to a projector or a TV every 10 seconds (I tried different remotes and different codes). I tried to make it as simple as possible :

[code] #include <IRremote.h>

IRsend irsend;

void setup()
{ }

void loop() {

irsend.sendNEC(0xAF5E827, 32);
delay(10000);
}

[/code]

Pin 3 in the library is set as output automatically so the setup part is basically empty.

I've also tried different versions of the IRremote library (version 2.8.0 was used here) and read a lot of material, also on this forum but I still can't find a solution.
Maybe someone could help?
Thanks!!!

It looks like you did not configure a send pin. You probably either have to use an other constructor or use the begin method.

https://arduino-irremote.github.io/Arduino-IRremote/classIRsend.html

Or is there some default send pin perhaps?

1 Like

IR LEDs requires significant current, it will not work from arduino pin. You need to use a transistor to drive it

Are you using a cell phone camera to verify that the IR LED is working?

That tells me that you are using example code for an old version (<3.0) of the IRremote library. What version of the IRremote library do you have installed? Older code may not work with the new library versions. If you have the newer version (3.0 or greater) installed use the examples from that library. If you look, with the library manager, you will see that you can install older versions if need be.

Thanks for your answer! The Pin 3 is said to be a default one, but I also tried to put irrecv.enableIRIn(); and just set pin 3 as an output, but it did not seem to have any effect.

That’s a good hint!
But I tried to turn it on simply with digitalWrite function and I could see on my cellphone that it was quite bright. Do you think it still may need more juice to run?

Exactly, I am checking it with my cell phone camera.
And I installed an older version of the library- 2.8.0 specifically to match old tutorials.
Newer version also has a different function to send a signal, which needs an address and a command to be put separately and I failed to figure out what to put there, tbh. Because then I just put a constant part of the IR code as an address and a changing part as a command it didn’t work as well.

is it works now? Do you test it with receiver rather than

In addition to written above I tried Irsend.setSendPin (3) and it also didn’t work

No it doesn’t… I tested it by just using a digitalWrite function and on my cellphone it was pretty bright and there was just nothing at all with the irsend.sendNEC function

If you are interested, here is a simple code to read a remote and return the code and the address for the button pressed and the protocol (type) of the remote that you are using.

#include <IRremote.hpp>

const byte IR_RECEIVE_PIN = 4;  //  ************** note pin number

unsigned long keycommand = 0;  // Individual key code
unsigned long keyaddress = 0;  // key address
decode_type_t remoteprotocol;  // remote protocol

bool newIR = false;

const char *thisProtocol[] = {"UNKNOWN", "PULSE_DISTANCE","PULSE_WIDTH","DENON","DISH","JVC","LG","LG2","NEC","PANASONIC",
                              "KASEIKYO","KASEIKYO_JVC","KASEIKYO_DENON","KASEIKYO_SHARP","KASEIKYO_MITSUBISHI","RC5","RC6",
                           "SAMSUNG","SHARP","SONY","ONKYO","APPLE","BOSEWAVE","LEGO_PF","MAGIQUEST","WHYNTER"};

void setup()
{
   Serial.begin(115200);
   Serial.println("IR receive test");
   IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
}

void loop()
{
   checkIR();

   if (newIR)
   {
      printIR();
      newIR = false;
   }
}

void checkIR()
{
   if (IrReceiver.decode())
   {
      keycommand = IrReceiver.decodedIRData.command;
      keyaddress = IrReceiver.decodedIRData.address;
      remoteprotocol = IrReceiver.decodedIRData.protocol;

      if ((IrReceiver.decodedIRData.flags & IRDATA_FLAGS_IS_REPEAT))
      {
         IrReceiver.resume();
         return;
      }

      IrReceiver.resume();
      newIR = true;
   }
}

void printIR()
{
   Serial.print("decoded command = ");
   Serial.print(keycommand, HEX);
   Serial.print("     decoded address = ");
   Serial.print(keyaddress, HEX);
   Serial.print("     decoded protocol = ");
   Serial.println(thisProtocol[remoteprotocol]);
   Serial.println();
}

Thanks a lot! I try that with a newer library version! Can it be that I am using an Arduino Micro and not Uno the cause of the problem?

I don't know the Micro at all. Isn't it a 3.3V board?

Have you read the readme.md GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols
Most questions are answered there. An do not hesitate ti use the Simple* examples of the library.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.