ATmega328 random reset

Three possibilities come to mind:

  1. Lack of decoupling capacitors. See previous posts. The most important one is between Vcc and Gnd of the atmega328p. I suggest you solder one directly across the Vcc and ground pins of the chip, on the underside of the board, with really short leads.

  2. Power supply brownout, e.g. if the peak fan current is too much for either the 7805 or the supply that is providing 12V. Need to know more about the fan and the supply before we can discount this as a possibility.

  3. Software problem.