This question already has an answer here:

While tyring to figure out how to best control a 12V device from a raspberry pi or arduino I ran into the following image: enter image description here

Now I'm wondering, what is D1 doing there? What's the use of that one?


marked as duplicate by Brian Drummond, Community Oct 29 '16 at 15:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


When the transistor switches open, energy stored in the motor can cause a back emf and destroy the transistor so the diode provides a current path for that energy to prevent this happening.

The same applies to switching any magnetic component such as a relay, a solenoid or a transformer.


Not the answer you're looking for? Browse other questions tagged or ask your own question.