Problem moving projects from Arduino Uno to Atmega328p on a breadboard

Hi,

I have tried to program an Atmega328p on a breadboard using the Arduino IDE and that worked fine.
But I encountered a problem when I tried to replace the Arduino Uno with an Arduino on a breadboard for some finished Arduino Uno projects.
The arduino starts to work for about half a second and then resets. This makes the whole setup flicker because I see the first part of the setup process repeating.
This happened with two entirely different projects so I suspect that I'm generally doing something wrong.

On the breadboard, I have the ATmega328p connected to a 16Mhz crystal, two capacitors, the Vcc/Vref and GND are connected on both sides (to the corresponding one) and RESET is connected to 5V.

Thanks in advance,
Marian

Did you put decoupling caps (100 nF) next to the MCU as well as some bigger (10 uF) caps on the power rail? sounds like you might be browning out. Are there any heavy loads being driven from the same rail that's powering your MCU?

I have a 10uF capacitor between 5V and GND and two 22pF between GND and the crystal pins.
Where do the decoupling caps go?
And yes, the 5V power rails powers the entire project with 64 LEDs, up to 16 are on at a time.

Similar things happened to me. Turned out it was power issue. If all wires are secured and components placed well on the breadboard, try switching to a more reliable power supply.

Where do the decoupling caps go?

100nF, as close to all power pins as possible.


Rob

Okay I added three 100nF capacitors between 5V and GND right next the Atmega and I replaced the 1A wallwart with a 2A wallwart. The circuit now seems to survive slightly longer but resets after about a second.

Do I also have to decouple two 74HC595 bitshifters?

Yes, you should have decoupling caps next to every chip. Try measuring the voltage of the wallwart and of the 5 volt rail while the program is running, if either voltage drops a lot when the LEDs turn on then you know you have power problems.