Arduino UNO EEPROM reset

If you have long leads to the 24V power supply, you may be experiencing large, destructive voltage spikes when switched.

See this tutorial: Pololu - Understanding Destructive LC Voltage Spikes