PCM Audio acts up on breadboard

Hi,

I’m building a little project where a sounds starts playing when an LDR triggers. I’ve used PCM and have the audio on the atmega. It works totally fine on the arduino uno, but for some reason when i move everything over to a breadboard the sound plays for 1 second until it abruptly restarts multiple times and sometimes in different tones. At some point it stops and the little speaker leaves a hum sound as if there’s power going through. First I thought that my 16Mhz crystal might be messed up but when I loaded a blink program it worked at perfect speed.

I ended up dummying my code down to the following, but the problem persists.

#include <PCM.h>
#include <avr/sleep.h> 

const unsigned char meow1[] PROGMEM = {
  129, 129, ...shortened..., 128, 128, 128, 
};


void setup()
{
    startPlayback(meow1, sizeof(meow1));
}

void loop() {
    delay(5000);
    startPlayback(meow1, sizeof(meow1));
}

I followed the official arduino docs to move everything over to a breadboard;

  • 10k resistor from V to reset
  • Both V to VCC
  • Both G to GND
  • 16Mhz crystal to X1, and X2
  • 22pF cap on the X1 and X2 line to G
  • Pin 13 to LED with 220 resistor

The tune plays at pin 11.

Is anybody aware of what this could be?

Thank you very much

Any supply decoupling capacitors?

I don't have that. I'm connecting to the 5v line of my Uno. Do I need them in that case?

EDIT: Oh man, I added a 100uf and it totally works. Thanks a lot.

Decoupling is absolutely essential for any digital logic chip, as you've discovered the symptoms of inadequate decoupling can be very confusing. Use a 100nF ceramic cap on (*) each and every supply pin to ground (And also on the AREF pin)

The 100µF is not going to be reliable for high-speed decoupling having too much stray inductance, but for audio
its worth keeping, just add 100nF ceramics to Vdd, AVdd (and AREF if using the ADC).

(*) Right on, as close as possible.