Strange output from IR transmitter

Hello. I have recently tried to run the code from IRremote.h library , an example code named SendRawDemo.cpp . But strange thing happened , this was the output of the code:

IR transmitter feedback led is blinking red on these commands , but i don't see IR light emitting any signal when i had checked it from phone camera. IR Receiver is working absolutely fine and i'm receiving codes normally, but transmitter doesn't work.
IR Transmitter is connected on pin 3 by default , but even that doesn't work.

Do you guys have any solution to this? I tried literally everything and still no luck.

We can't see your code.

Sorry , here's the code:

/*
 * SendRawDemo.cpp - demonstrates sending IR codes with sendRaw
 *
 * This example shows how to send a RAW signal using the IRremote library.
 * The example signal is actually a 32 bit NEC signal.
 * Remote Control button: LGTV Power On/Off.
 * Hex Value: 0x20DF10EF, 32 bits
 *
 * It is more efficient to use the sendNEC function to send NEC signals.
 * Use of sendRaw here, serves only as an example of using the function.
 *
 *  This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
 *
 ************************************************************************************
 * MIT License
 *
 * Copyright (c) 2020-2021 Armin Joachimsmeyer
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is furnished
 * to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 ************************************************************************************
 */
#include <Arduino.h>

/*
 * Define macros for input and output pin etc.
 */
#include "PinDefinitionsAndMore.h"

#include <IRremote.h>

// On the Zero and others we switch explicitly to SerialUSB
#if defined(ARDUINO_ARCH_SAMD)
#define Serial SerialUSB
#endif

void setup() {
    pinMode(LED_BUILTIN, OUTPUT);

    Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)  || defined(ARDUINO_attiny3217)
    delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor!
#endif
    // Just to know which program is running on my Arduino
    Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));

    IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin

    Serial.print(F("Ready to send IR signals at pin "));
#if defined(ARDUINO_ARCH_STM32) || defined(ESP8266)
    Serial.println(IR_SEND_PIN_STRING);
#else
    Serial.print(IR_SEND_PIN);
#endif
}

/*
 * NEC address=0xFB0C, command=0x18
 *
 * This is data in byte format.
 * The uint8_t/byte elements contain the number of ticks in 50 us.
 * The uint16_t format contains the (number of ticks * 50) if generated by IRremote,
 * so the uint16_t format has exact the same resolution but requires double space.
 * With the uint16_t format, you are able to modify the timings to meet the standards,
 * e.g. use 560 (instead of 11 * 50) for NEC or use 432 for Panasonic. But in this cases,
 * you better use the timing generation functions e.g. sendNEC() directly.
 */
const uint8_t irSignalP[] PROGMEM
= { 180, 90 /*Start bit*/, 11, 11, 11, 11, 11, 34, 11, 34/*0011 0xC of address LSB first*/, 11, 11, 11, 11, 11, 11, 11, 11/*0000*/,
        11, 34, 11, 34, 11, 11, 11, 34/*1101 0xB*/, 11, 34, 11, 34, 11, 34, 11, 34/*1111*/, 11, 11, 11, 11, 11, 11, 11,
        34/*0001 0x08 of command LSB first*/, 11, 34, 11, 11, 11, 11, 11, 11/*1000 0x01*/, 11, 34, 11, 34, 11, 34, 11,
        11/*1110 Inverted 8 of command*/, 11, 11, 11, 34, 11, 34, 11, 34/*0111 inverted 1 of command*/, 11 /*stop bit*/};

void loop() {
    const uint8_t NEC_KHZ = 38; // 38kHz carrier frequency for the NEC protocol

#if !(defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__))
    /*
     * Send hand crafted data from RAM
     * The values are NOT multiple of 50, but are taken from the NEC timing definitions
     */
    Serial.println(F("Send NEC 8 bit address 0xFB04, 0x08 with exact timing (16 bit array format)"));
    Serial.flush();

    const uint16_t irSignal[] = { 9000, 4500, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560,
            1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 560, 560, 560, 560,
            1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560,
            1690, 560, 1690, 560 }; // Using exact NEC timing
    IrSender.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), NEC_KHZ); // Note the approach used to automatically calculate the size of the array.

    delay(1000); // delay must be greater than 5 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal
#endif

    /*
     * Send byte data direct from FLASH
     * Note the approach used to automatically calculate the size of the array.
     */
    Serial.println(F("Send NEC 16 bit address 0xFB0C, 0x18 with (50 us) tick resolution timing (8 bit array format) "));
    Serial.flush();
    IrSender.sendRaw_P(irSignalP, sizeof(irSignalP) / sizeof(irSignalP[0]), NEC_KHZ);

    delay(1000); // delay must be greater than 5 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal

    Serial.println(F("Send NEC 16 bit address 0x0102, 8 bit data 0x34 with generated timing"));
    Serial.flush();
    IrSender.sendNEC(0x0102, 0x34, true, 0);

    delay(3000);
}

Your baud rates do not match
You start Serial at 115200, but your serial monitor is set at 9600. Hence the gibberish.
I make that mistake about once a week.

1 Like

Thank you i fixed the output , but still IR is not emitting light?

We can't see your schematic (also, some phone cameras now have better IR filters)

Schematic is simple , i just connected IR transmitter to +5V , GND, and data to pin 3. I checked it from phone camera with IR filter but i don't see IR light

Set up an IR receiver on another Arduino to receive your codes and feed them to the serial monitor.

I have tried that , doesn't emit the IR light.

Ok
In order to help further we will need to see pictures of your setup and the code for the receiving IR Arduino.
It's likely either a wiring or software issue but we'll need all the info to tell for sure, please.

Sorry, but can't find where it's set that the IR output is on pin 3?

RV mineirin

In IRremote library default output IR pin is 3.

Receiver is working absolutely fine , i tried to send HEX code i got from TV remote , but transmitting isn't working at all.
What do you need from me to send?

Everything, please
Pictures of the wiring for the IR sending Arduino
Pictures of the wiring of the IR receiving Arduino
Code for the IR receiving Arduino

tks,
which kind arduino are using?

Receiving code:

#include <IRremote.h>


int RECV_PIN = 5; // the pin where you connect the output pin of IR sensor

IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
  
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(led, OUTPUT);
}
void loop() {

if (irrecv.decode(&results))// Returns 0 if no data ready, 1 if data ready.
{
int readResults = results.value;// Results of decoding are stored in result.value
Serial.println(" ");
Serial.print("Code: ");
Serial.println(results.value); //prints the value a a button press
Serial.println(" ");
irrecv.resume(); // Restart the ISR state machine and Receive the next value


    
}
 

}

Transmitting code:

/*


  • MIT License
  • Copyright (c) 2020-2021 Armin Joachimsmeyer
  • Permission is hereby granted, free of charge, to any person obtaining a copy
  • of this software and associated documentation files (the "Software"), to deal
  • in the Software without restriction, including without limitation the rights
  • to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  • copies of the Software, and to permit persons to whom the Software is furnished
  • to do so, subject to the following conditions:
  • The above copyright notice and this permission notice shall be included in all
  • copies or substantial portions of the Software.
  • THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  • INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  • PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  • HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  • CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  • OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

*/
#include <Arduino.h>

/*

  • Define macros for input and output pin etc.
    */
    #include "PinDefinitionsAndMore.h"

#include <IRremote.h>

// On the Zero and others we switch explicitly to SerialUSB
#if defined(ARDUINO_ARCH_SAMD)
#define Serial SerialUSB
#endif

void setup() {
pinMode(LED_BUILTIN, OUTPUT);

Serial.begin(115200);

#if defined(AVR_ATmega32U4) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL) || defined(ARDUINO_attiny3217)
delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor!
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " FILE " from " DATE "\r\nUsing library version " VERSION_IRREMOTE));

IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin

Serial.print(F("Ready to send IR signals at pin "));

#if defined(ARDUINO_ARCH_STM32) || defined(ESP8266)
Serial.println(IR_SEND_PIN_STRING);
#else
Serial.print(IR_SEND_PIN);
#endif
}

/*

  • NEC address=0xFB0C, command=0x18
  • This is data in byte format.
  • The uint8_t/byte elements contain the number of ticks in 50 us.
  • The uint16_t format contains the (number of ticks * 50) if generated by IRremote,
  • so the uint16_t format has exact the same resolution but requires double space.
  • With the uint16_t format, you are able to modify the timings to meet the standards,
  • e.g. use 560 (instead of 11 * 50) for NEC or use 432 for Panasonic. But in this cases,
  • you better use the timing generation functions e.g. sendNEC() directly.
    */
    const uint8_t irSignalP PROGMEM
    = { 180, 90 /Start bit/, 11, 11, 11, 11, 11, 34, 11, 34/0011 0xC of address LSB first/, 11, 11, 11, 11, 11, 11, 11, 11/0000/,
    11, 34, 11, 34, 11, 11, 11, 34/1101 0xB/, 11, 34, 11, 34, 11, 34, 11, 34/1111/, 11, 11, 11, 11, 11, 11, 11,
    34/0001 0x08 of command LSB first/, 11, 34, 11, 11, 11, 11, 11, 11/1000 0x01/, 11, 34, 11, 34, 11, 34, 11,
    11/1110 Inverted 8 of command/, 11, 11, 11, 34, 11, 34, 11, 34/0111 inverted 1 of command/, 11 /stop bit/};

void loop() {
const uint8_t NEC_KHZ = 38; // 38kHz carrier frequency for the NEC protocol

#if !(defined(AVR_ATtiny25) || defined(AVR_ATtiny45) || defined(AVR_ATtiny85))
/*
* Send hand crafted data from RAM
* The values are NOT multiple of 50, but are taken from the NEC timing definitions
*/
Serial.println(F("Send NEC 8 bit address 0xFB04, 0x08 with exact timing (16 bit array format)"));
Serial.flush();

const uint16_t irSignal[] = { 9000, 4500, 560, 560, 560, 560, 560, 1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560, 560,
        1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 560, 560, 560, 560,
        1690, 560, 560, 560, 560, 560, 560, 560, 560, 560, 1690, 560, 1690, 560, 1690, 560, 560, 560, 1690, 560, 1690, 560,
        1690, 560, 1690, 560 }; // Using exact NEC timing
IrSender.sendRaw(irSignal, sizeof(irSignal) / sizeof(irSignal[0]), NEC_KHZ); // Note the approach used to automatically calculate the size of the array.

delay(1000); // delay must be greater than 5 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal

#endif

/*
 * Send byte data direct from FLASH
 * Note the approach used to automatically calculate the size of the array.
 */
Serial.println(F("Send NEC 16 bit address 0xFB0C, 0x18 with (50 us) tick resolution timing (8 bit array format) "));
Serial.flush();
IrSender.sendRaw_P(irSignalP, sizeof(irSignalP) / sizeof(irSignalP[0]), NEC_KHZ);

delay(1000); // delay must be greater than 5 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal

Serial.println(F("Send NEC 16 bit address 0x0102, 8 bit data 0x34 with generated timing"));
Serial.flush();
IrSender.sendNEC(0x0102, 0x34, true, 0);

delay(3000);

}

Arduino Uno.

After correcting the speed of the series, what appears printed on it
at the place where you printed garbage?

Send NEC 8 bit address 0xFB04, 0x08 with exact timing (16 bit array format)
Send NEC 16 bit address 0xFB0C, 0x18 with (50 us) tick resolution timing (8 bit array format)
Send NEC 16 bit address 0x0102, 8 bit data 0x34 with generated timing
Send NEC 8 b

Ir sending schematic : IR Transmitter connected VCC +5V, GND to GND , and DATA to pin 3.
IR receiving schematic , same except data pin is on 5.

Just a simple schematic and example