[Solved] Randomly occurring 291 cps square wave, for 1/2 second. From where?

At random times (perhaps twice a day as I work on Arduino), one or more outputs will produce a square wave for about 1/2 second. I might see it in an LED or hear it in my speaker, or both.

I'm unable to reproduce the effect at will, so am unable to trace the source. It can happen first thing after powering up, or seemingly any time later.

I measured the frequency to be 291cps, and I'm using an Atmega1284p AVR. Does anyone know the cause and/or how to prevent it?

Not without seeing your code and how your schematic is wired up.

CrossRoads: Not without seeing your code and how your schematic is wired up.

Thank you for offering to look into it. However, there are currently about 300 connections on the breadboard, and 3117 lines of code in the sketch. I wouldn't ask anyone to dig through all that.

But I just now found the cause of the 1/2 second, 291cps tone. It's whenever something updates the EEPROM! ...so not really a problem. Evidently saving to each memory cell draws a lot of current.

Hearing it in the speaker means I need better grounding (using the star grounding method).

And I solved the problem of it causing the super-bright LED to flicker, by adding a diode in series with the base of the transistor that drives the LED. Doing so lowers the voltage on the transistor base so the amount of voltage needed to cause current to flows through it from the processor isn't reached so easily.

NOTE: (The comment above says "400 cps", as was in my original title. I later measured the frequency at 291cps, and then updated the title.)

Maybe a little work on the power rail would help.
Adequate power supply.
More decoupling caps.