Suitable wire for DC motor

Please post your code plus a circuit diagram and give details of the motor and driver you are using (links to datasheets would be ideal). We're not very good at guessing.

As described your symptoms make very little sense, but if you are really managing to burn 18AWG wire then there is a lot more than 5A flowing and your wiring is very wrong.

Steve