Problem with IR transmitter

Please give me some advice

my experimental with RF 433mhz ,315mhz went well, but IR part has given me a lot of trouble
been order different IRs but none of them go well for me. this is my latest part YwRobot IR transmitter http://www.ebay.com/itm/Wrobot-Digital-38KHz-IR-Sensor-Kit-/281002304748?hash=item416d0ae4ec
I used exactly senddemo code from ir library but never see IR lighted up(using camera viewer)
please take a look at my wiring .. if you see any problem.

Thankyou very much for you time. :slight_smile:

/*
 * IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
 * An IR LED must be connected to Arduino PWM pin 3.
 * Version 0.1 July, 2009
 * Copyright 2009 Ken Shirriff
 * http://arcfn.com
 */

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

Where does the IR pin get declared? there is no pin setup in your sketch to drive the IR transmitter.

Doc

In the IRDemo.ino you can read:

  • IRremote: IRsendDemo - demonstrates sending IR codes with IRsend
  • An IR LED must be connected to Arduino PWM pin 3.

The library use timer, on Arduino Uno timer 2 so you can use pin 3 (or 11)

void IRsend::mark(int time) { // Sends an IR mark for the specified number of microseconds.  The mark output is modulated at the PWM frequency.
  TIMER_ENABLE_PWM;          // Enable pin 3 PWM output
  delayMicroseconds(time);
}

You have the Mega. You can use 5 different timer. Open the file IRRemoteInt.h under library e see something like this:

// Arduino Mega
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
  //#define IR_USE_TIMER1   // tx = pin 11-12
  //#define IR_USE_TIMER2   // tx = pin 9-10
  //#define IR_USE_TIMER3   // tx = pin 2-3-5
  #define IR_USE_TIMER4     // tx = pin 6-7-8
  //#define IR_USE_TIMER5   // tx = pin 44-45-46

On my library I use TIMER4 (define without comment simbol), so pin 6,7 or 8

EDIT: where you download the library? From your link I can see a zip with a very very old IRRemote library (I think not compatible with Mega) !!!
Use this link: GitHub - Arduino-IRremote/Arduino-IRremote: Infrared remote library for Arduino: send and receive infrared signals with multiple protocols

Thanks nid69ita will try that
Thanks Docedison I though it was declared in the .h file let me take a closer look at the sketch.

nid69ita you are the man, you pointed out the exactly the problem
checked IRremoteInt.h , mega2560 using pin9 for ir transmitter.. run the sketch again ..wow panasonic tv is ON.
Thanks alot man. have a great day.

Happy to be useful. Hi. :slight_smile: