Electronic – arduino – Should I have had a resistor before the transistor

arduinotransistors

I've recently started playing with an Arduino and learning about circuit's. I was trying to learn a bit about using some transistors as a switch and I think in the process I ended up ruining one of the pins on my Arduino. When set to HIGH the pin only outputs 0.5 now rather than the 4.6ish the rest of the pins do.

The circuit I built involved two transistors. One to control a 12v fan via a PWM signal off the Arduino and another to act as a switch for turning on/off an ATX power supply which I used to provide power for the fan.

Here's an approximation of the circuit. I'm not really sure how to properly diagram it.

schematic

simulate this circuit – Schematic created using CircuitLab

To try and explain a bit, The Arduino was powered via the USB connection to the computer. Pin 11 is setup as a PWM output to control the speed of the fan. Pin 12 is setup as a HIGH output to switch on an external ATX power supply when the Arduino board turns on. I use one of the 12v rails on the power supply to power the fan, and have it's ground connected to the Arduino's ground.

Not shown in the diagram is a simply push button to increase the speed of the fan and a 7-segment led display showing a number representing the speed. I don't think these are related to my pin problem and I'm fairly certain it was all wired up correctly.

After doing a little more research I think the main issue which caused my pin problems is I should have had a current limiting resistor in between the Arduino pin and the base of the transistor. Is conclusion accurate?

Any additional comments/criticisms welcome.

Best Answer

Yes, your conclusion is correct. Just insert a 1K resistor in series with the base. But first try with a 10 K resistor and then keep on reducing it by 1K. For a more accurate value of the resistor, use this formula:

$$ R_{base} \approx {h_{FE}} \times \frac {V_{OH} - 0.7V} {I_{FAN}} $$

Where

  • hFE is the transistor's current gain,
  • IFAN the fan current as measured when connected to the 12VDC source and
  • VOH the microcontroller's output high level voltage.