SAnother angle with arduinoSorry the wiring is messy, I only have small breadboards. The far top left row is ground and the front left is 5vI have a sketch that sends an IR code every second. It works fine (the correct code is received by my receiving Arduino next to it) on the Arduino but when I try to move the sketch to an ATMega328P-PU, the IR no longer sends (the serial monitor output still works).

I have used a camera to look at the IR LED and it just doesn't flash on the ATMega328 but does on the Arduino (and I have tested my LED, it does work). It uses pin 3 on the Arduino, so I use pin 5 on the ATMega328.

Are there extra components that are needed to make PWM work without the Arduino board? I am honestly stumped so any help would be appreciated. Thanks in advance.


#include <IRremote.h>

IRsend irsend; //Setup the IR transmitter

int codeToSend;
int team = 1;
int damage = 0;

void setup() 

void loop()
    if (team > 8) team = 1;
    if (damage > 99) damage = 0;

    if (damage > 9) codeToSend = (String(team) + String(damage)).toInt();
    else codeToSend = (String(team) + "0" + String(damage)).toInt();

    irsend.sendNEC(codeToSend, 32);
  • 1
    If I take your question literally, "no". However, I'm guessing you actually want to know why this isn't working on a breadboard. For that, it would be helpful to have in-focus picture(s) of your board's actual wiring, in one frame if that's possible.
    – timemage
    Jan 23 '21 at 14:57
  • I added a photo, sorry the wiring is messy, I only have small breadboards. Far left is ground, front left is 5v. You can't see but the capacitor connects the ground and 5v rows and the resistor connects pin 1 to 5v (10Kohms).
    – Patrick
    Jan 23 '21 at 16:38

NOTE: The following comment was left on this answer (below) and indicates the principal problem the original poster was having above and beyond not having a resistor, etc.

SOLVED - my breadboard was broken on that rail. :/

Current limiting

What you have pictured looks alright for the most part with the exception of there appearing to be no current limiting resistor for the IRED. It is possible that you've damaged the IRED by setting the pin HIGH for an extended period of time. It is also technically possible to have damaged the AVR (or just the one pin) by doing that, though this wouldn't be my first guess.

Typical forward voltages for an IRED around around a volt. An AVR pin's maximum rating current is 40mA. To get proper logical levels out of it, it should be less than 20mA. You could perhaps operate near 30mA, since you're not doing much else with the AVR's ports and you're not trying to get logic level voltages out of the pin. For that you'd need a resistor in series with the IRED that is something like (5V - 1V) / 0.030A, approximately 133 ohms.

Modified image of board showing where/how a resistor might be connected.


When people use IRED to make remotes, it is normal to use a transistor to offload the current requirement from the MCU. And also to operate the IRED above its continuous operation current, closer to it's rated peak/pulse current. Operating in the low tens of mA often only gets you a meter or so.

That arrangement might look something like the following for higher current pulses around 80mA:

Using a transistor to switch an IRED


  • I'm not able to read your reset resistor well. If you're not, do measure it to make sure it's 10K. If in doubt, remove it. There is a weaker internal pullup on the AVR reset and it's usually enough. If you wanted you could wire the reset signal over to the UNO reset pin to take advantage of the external pullup, reset switch, and DTR reset mechanism of the UNO itself.

  • You may want to add .1uF capacitors from your VCC and AVCC pins to ground. You can often go without while experimenting, but when you're switching higher currents they'll become more important.

  • I have a bunch of those jumpers with the rounded (cylindrical) ends. They often don't make good connections on breadboard. You can save some trouble sometimes with "Dupont" type jumpers or just making your own out of solid 22awg hookup wire.

  • When I put the IRLED into my other Arduino with the same circuit and sketch set up, the IRLED works, so I don't think it's damaged. I have added a 133ohm resistor (100+33) as you said and tried again with a different 328p-pu but still no luck. The resistor on my reset is definitely 10kohm as I tested it with a multimeter
    – Patrick
    Jan 23 '21 at 19:00
  • I'll look over the image some more, but I don't know what expect to find. The fact that it's still operating over serial rules out a lot of ideas. With respect to the current limiting, that's good to hear, because you should have that no matter what else is going on.
    – timemage
    Jan 23 '21 at 19:03
  • It would appear that digital pin 3 (pin 5 of 328) doesn't work at all without the board. I uploaded a simple led blink sketch to the MCU and that worked fine using pin 2 (pin 4 of 328), but not 3 (pin 5 of the 328). This would suggest that pin 5 of the 328 doesn't work at all, but it must do as the sketch works with the chip in the Arduino board using pin 3. This goes to both my 328 chips and boards. Any ideas?
    – Patrick
    Jan 23 '21 at 20:20
  • On an official UNO PD3 doesn't go anywhere except the header. I expect no difference on any normal clone. It's my suspicion that if you put it back into the board it will continue to fail to work there. If not that, then perhaps one of those jumpers is not making very good contact.
    – timemage
    Jan 23 '21 at 20:29
  • 2
    SOLVED - my breadboard was broken on that rail. :/ Thank you so much for your time and help.
    – Patrick
    Jan 23 '21 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.