IR transmitter not functioning

I am working on a universal remote project. I was able to get the receiver to work and decoded the remotes I want to reduce. The issue lies with transmitting. I get no response except from the Serial Monitor when triggering the switch-case, however I do know the LED works from a side test. I tried swapping the IR LED with a normal one as well as the camera trick, to no avail. I am a total noob at electronics and have limited experience with C++, so any help would be greatly appreciated. :grinning_face_with_smiling_eyes:

I am only able to embed one pic as I'm new, so I will hopefully post the rest of the photos in the comments...

What'd I do wrong?

What I used to decode the IR signals. I cannot remember the source from where I obtained the code.

#include "IRLibAll.h"

//Create a receiver object to listen on pin 2
IRrecvPCI myReceiver(2);

//Create a decoder object 
IRdecode myDecoder;   

void setup() {
  delay(2000); while (!Serial); //delay for Leonardo
  myReceiver.enableIRIn(); // Start the receiver
  Serial.println(F("Ready to receive IR signals"));

void loop() {
  //Continue looping until you get a complete signal received
  if (myReceiver.getResults()) {
    myDecoder.decode();           //Decode it
    myDecoder.dumpResults(true);  //Now print results. Use false for less detail
    myReceiver.enableIRIn();      //Restart receiver

The deets from decoding. From what I understand it is NEC 32-bit:

My main file. I defined the hexadecimals at the top. The one I am currently trying to transmit is 0x41FF4887 labeled "powerRocket".

#include <IRremote.h>

//defines all. The Projector remote is NEC 32-bit, found using the IRlibAll. 
#define powerButton 0x807F00FF
#define menu 0x807F807F
#define source 0x807F906F
#define OK 0x807F609F
#define play 0x807FC03F
#define eggsit 0x807FD02F
#define lower 0x807F02FD
#define loud 0x807F12ED
#define mute 0x807F22DD
#define up 0x807FA05F
#define down 0x807F20DF
#define left 0x807F40BF
#define right 0x807F50AF

//The RocketFish remote is NEC as well
#define powerRocket 0x41FF48B7
#define oneRocket 0x41FFA05F
#define twoRocket 0x41FFE01F
#define threeRocket 0x41FFD827
#define fourRocket 0x41FF906F
//IR receiv, define results
const int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;

IRsend irsend;

void setup() {
//Sets up serial communication and enables IR receiver
Serial.println("ready to receive");

void loop() {
//if statement taking any incoming pulses and doing as follows
if (irrecv.decode(&results)){
  Serial.println(results.value, HEX);
  switch (results.value){
    case powerButton:
      irsend.sendNEC(powerRocket, 32);
//continue receiving: delay

I haven’t tried sending stuff via an IR link, but when I do via a wired connection the most frequent cause of failure ( at the RX end) is due to me sending at the wrong speed. So assuming that your IR LED is working, can you first check that your RX is getting “something” … then check that the something is at the correct speed and or format that can be decoded by the reciever.

So, are you saying that this code

  Serial.println(results.value, HEX);
  switch (results.value){
    case powerButton:

prints "0x807F00FF" but then does not print "powerButton"?

Do you think that is just from the RX end or should I also adjust the baud rate?

I can get the println to work when I press the power button on my first remote, but I can't get the irsend.sendNEC to transmit anything to my IR LED after that.

switch (results.value){
    case powerButton:
      irsend.sendNEC(powerRocket, 32);

Are you sure you know the exact TX Pin and that this is correctly defined?

If you are using this IRRemote library

please check the examples! You may have to download and/or just add the file PinDefinitionsAndMore.h and probably some further lines (see the SendDemo at github above).

That might help to get it working ... Good luck!

1 Like

I posted my comment as a fairly generic statement, in other words the apparent failure of the RX can have many route causes. I hadn't looked at the detail of your code. On a different tack, in a recent project of mine (in which I had an opto - isolator) if I set the data rate to 9600 the edges of the "bits" were very curved ( almost blurring into each other ) and the link didn't work... until I reduced the baud rate to 1200. The opto - isolator (LED or transistor) couldn't switch fast enough.

I guess you are talking about transmitting serial data via IR, aren't you? The TO seems to send NEC IR Remote signals. These are usually transmitted as a sequence of gaps and pulses modulated at 38 kHz. You may find a very comprehensive description here:

The part on transmission is here:

I am using the IRMP lib to decode BOSE/JVC code and to convert them to control a technics tuner with a NANO. Works great.

No, perhaps I didn't explain it correctly. Also I may have misunderstood your problem. My comments were meant to say : - before you investigate your code, can you confirm that the IR link works as intended, and that it can pass data uncorrupted. Is ther a way that you can check the hardware is ok?

Thank you guys so much for your help! I added "PinDefinitionsAndMore.h" and it solved everything. The tutorials I was following said there wasn't a need to define Pin 3, but they didn't even include this header file.

You guys made my day!

Sometimes solutions are hard to find but easy to install ... That's better than the other way around.

Glad, I could assist!

If you are going to make more use of IR applications, I suggest to have look at the links I provided above regarding IRMP and the explanations there. That gives you the best insight!

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