Current Sensor

I have an arduino uno and I use it to control a stepper motor. It is attached to a adafruit motor shield that can sense voltage, but I'm about to switch to an arduino motor shield that can sense voltage and also sense current. How would I write the code for the arduino to sense the current going to the motor and shut off when it reaches a certain value? The motor shields keep burning up and I'd like to keep that from happening to save my company a little money, and it would help if I could put some kind of coded stop so the motors don't get fed too much current.

You'll have to get the specs for the motor shield to find out how it "reports" the current information.

It would be better to find the root cause, or maybe you just need a higher-power motor shield or a heatsink.

You'll have to set the safe-current threshold lower than whatever blows the drivers, so the system may end-up shutting-down all of the time instead of burning-up. It's easier to recover because you'll just have to wait for it to cool-down instead of replacing components, but it will still interrupt whatever the motor is doing.

As stated above, see what the documentation is on this board and then, if it isn't completely clear on a value, hook an ammeter between the output and the motor and increment the current value until you reach the desired threshold and then use that as the limit. I have a Seeed motor shield that I know the output is a scale of 1-2000 or something similar to that. So if the current value is the same then you can keep increasing it by 100 or so until you reach your threshold and then set that (ie: if > 1400 then stop)