2222a transistor as a switch

Always use a fly back diode on a DC coil relay/solonoid.
Show your code.
Schematic, YES!
What is the coil resistance?