Problems with Arduino Mega/IRsend()

i am new to arduino, but i have experimented very much in the last 2 weeks.

My problem: I have one IRdiode to collect IR-Codes (which works fine) at port 40 and an IR-LED at PWM Port 3 of my Arduino Mega.

I just opened the IRrecord-Example from the IRremote Library, changed the pin numbers and uploaded it to my Arduino.
Recieving and storing the IR-Codes works fine, but if i push my Button is says in the Serial-Console that he is sending out the code,
but it seems that no Code has left the IR-LED (even a second Arduino + IR-Reciever didnt find any IR-Light).
My IR-LED is a OSRAM SFH 409.
I connected it with the long lead over a 220 Ohm resistor(do i need it?) to (PWM) Output 3 like mentioned in the Example pde.
The Short lead is connected to ground.
(I even tried it reverse to exclude this source of error).

Does this IR-LED work for my intention? Or did i connect anything wrong?

What do you mean you changed the pin numbers?

From my understanding, IR transmission with this library works on Timer 2B. On an ATmega328P that is pin PD3, or digital pin 3. On an ATmega1280 (your Arduino Mega) Timer 2B is PH6, or digital pin 9.

So maybe try hooking up your LED to digital pin 9? Your connections sound right otherwise. Also make sure you configure the pin as an output with pinMode(9, OUTPUT).

Check out our new shield:

thank you, here was the mistake, i didnt now, that it is pin 9 on the MEGA.
And after connecting it to pin 9 I also had to define pin 9 as output, which normaly is made by IRremote.cpp,
but it sets pin 3 as output, this would only work for the smaller arduino 2009
Btw. is there a page, where i can find this pin dependics?

Now everything seems to work fine, Thank you! :slight_smile:

Btw. is there a page, where i can find this pin dependics?

Well, if you look at the bottom of our Gadget Shield page you will see a table that shows how pins and timers compare between the Duemilanove and the Mega. It doesn't cover all the Mega pins.

Check out our new shield: