Working my way through the tutorials, and trying to truly understand what all the comonents do in each one. I’m stumped on this one, though. (I’ve attached an image of it, and it’s also on Page 71 of this Guide: http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Kits/SFE03-0012-SIK.Guide-300dpi-01.pdf)
Here’s how it looks to me: 5V is provided to the bottom side of the of the relay’s coil, but can’t go anywhere because the transistor is open, preventing the 5V from getting to GND (and because of the diode, which allows voltage to flow only in the opposite direction). When the transistor is switched “on”, the 5V can get to GND, and the coil is activated. So far, so good. And the diode doesn’t seem to enter into the basic functioning of the circuit, right?
But the diode is there to prevent damage to the transistor, from the voltage spike that can come out of the coil when power to it is shut down (that’s what the Sketch comments say). My question is, HOW does it protect the transistor?
When Pin 2 goes LOW, the transistor goes “open”, so any voltage coming from the coil can’t go THROUGH the transistor, because it’s no longer connected to GND. But I guess the voltage going TO the transistor is what might damage it. So how does the diode protect it? IOW, why is the voltage spike coming out of the top of the coil going to go through the diode, and back to the bottom (5V) side of the coil, instead of to the transistor?
Thanks for anyone’s simple explanation.