Arduino Randomly Freezing During Long Jobs

Interesting is one word! :0

Serial.print() everywhere sounds like a good plan right now, and it allows me to procrastinate further in the knowledge that I really need to rebuild my electronics from scratch. I'm a neat, careful worker, but the stripboard has been modified a few times since the original design, and I must've made a mistake somewhere. While building the machine I learned how to make custom boards anyway, hopefully something will show up soon before I get to that stage. Next time I fancy either using custom drivers (Allegro A4988) or Darlington arrays fed from a pair of 74HC595s to keep my pin-count low and allow me half-wave control instead of the klutzy two-wire config I'm using now. I'm also tempted to use opto-isolators between the Arduino and the control board, though I'm sure that's just overkill, an no-one would ever bother?

Without the servo control board connected to the Arduino the code runs fine, which suggests it's a hardware problem.

When everything's connected it works for anything up to 15 hours, then stalls between commands, which suggests it's a software problem.

:roll_eyes:

@dc42

Your analysis of the HardwareSerial code is a little beyond my comprehension I'm afraid, but I have a pin free so I'll try your suggestion in a day or so. Thank you.