I am bit confused, I know it is very hard for you to suggest without knowing the complete details. But please suggest me as per your experience. I am powering my micro controller with 12V supply and able to read this value using ADC. My requirement says if I detect the failure of 12V supply I should be in a position to smoothly stop the motor. How is it possible? If my 12V is lost my code will not be executing. What are the different methods i can approach this to solve it either software or hardware or both? Please advise.