Electronic – arduino – How to energize a 12v relay coil using a 2N2222 bipolar transistor

arduinomosfetrelaytransistors

I'm relatively new to working with transistors, and I'm having some trouble getting this circuit to work. I want to use an Arduino's I/O pins (5V out) to energize a 12V relay coil. To do this, I'm powering the Arduino with 12 volts via the power port on the Arduino. For my transistor circuit, I'm pulling from the Vin pin on the Arduinio, which is also 12V.

I cannot figure out how to make it so that flipping an i/o pin from 0v to 5v switches the transistor, this allowing 12v to go across the relay coil.

I know the equations for the operating regions and I'm assuming I'm trying to drive the transistor into active by having Vbe > 0.7V, but I don't really know how to set up the circuit to properly regulate this.

Best Answer

This question has probably already been answered 100's of times. But here is maybe the 201'st time.

Use a circuit that looks like this:

enter image description here