# Using transistor as a switch

**URL:** <https://forum.arduino.cc/t/using-transistor-as-a-switch/379256>\
**Category:** General Electronics\
**Created:** [April 12, 2016, 10:57pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256 "2016-04-12T22:57:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![kcoke](https://avatars.discourse-cdn.com/v4/letter/k/ccd318/32.png) [@kcoke](https://forum.arduino.cc/u/kcoke)\
**Post date:** [April 12, 2016, 10:57pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/1 "2016-04-12T22:57:25Z")

</div>

I have a 37v LED panel and a IRF540n transistor. I want to use the transistor as a switch, but I don't want to burn down my Arduino. I have a few questions I can't seem to figure out the answer to.

1. Do I need to put a resistor between the Arduino and the gate of the transistor? If so, is it because in order to protect Arduino from short circuits, but normally it doesn't need to be there? doesn't the gate only 'give out' electricity?

2. How to know how big of a resistor to put between the gate and Arduino? does it depend on the other device's power or there's just a general resistor I can use in all cases regardless if I power 10v device or 40v device?

3. The LED panel doesn't have the 'shell', where do I put the ground wire coming from Arduino to?

Thank you for your time.

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [April 12, 2016, 11:08pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/2 "2016-04-12T23:08:29Z")

</div>

Use the logic version, IRL540.  
What is a shell?  
Use the Q7 example Replace the relay with the panel:  
You will not need D9

---

<div class="post-metadata">

**Author:** ![kcoke](https://avatars.discourse-cdn.com/v4/letter/k/ccd318/32.png) [@kcoke](https://forum.arduino.cc/u/kcoke)\
**Post date:** [April 12, 2016, 11:13pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/3 "2016-04-12T23:13:21Z")

</div>

Thanks! There's no way I can use it with 'IRL540'? I also have 2n3904 transistor, can I use that instead? I'm trying to learn about electronics, but I've been stuck on this for the last 4 days.

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [April 12, 2016, 11:27pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/4 "2016-04-12T23:27:56Z")

</div>

Do you have a link to the panel?  
.

---

<div class="post-metadata">

**Author:** ![Wawa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/wawa/32/1211303_2.png) [@Wawa](https://forum.arduino.cc/u/Wawa)\
**Post date:** [April 12, 2016, 11:43pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/5 "2016-04-12T23:43:42Z")

</div>

Do you have a link to the LED panel.  
How are you supplying the LED panel.  
Does it have some sort of inbuild or external current limiting.

Non-logic fets need 8-12volt gate drive. Arduino only has 5volt available.  
If you use the IRF540, you run the risk of not fully switching the mosfet 'on', maybe resulting in overheating.  
Two resistors are usually used between Arduino pin and gate.  
A 10k resistor from Arduino pin to ground to keep the gate firmly grounded during Arduino bootup.  
And a ~220ohm resistor between Arduino pin and gate, to limit current during switching (the gate acts as a capacitor that has to be charged/discharged).  
Leo..

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [April 13, 2016, 12:14am UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/6 "2016-04-13T00:14:44Z")

</div>

> I have a 37v LED panel and a IRF540n transistor.

Is that correct or did you mean 3.7 volt?

---

<div class="post-metadata">

**Author:** ![gpsmikey](https://avatars.discourse-cdn.com/v4/letter/g/5daacb/32.png) [@gpsmikey](https://forum.arduino.cc/u/gpsmikey)\
**Post date:** [April 13, 2016, 12:37am UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/7 "2016-04-13T00:37:29Z")

</div>

Actually, Wawa meant IRF540 - the IRF540 (the "L" indicates Logic level, "F" indicates a standard part) requires about 10 volts on the gate to fully turn on (saturate), the IRL540 can be driven into saturation around 5v (which is what the 5v Arduino can put out). The resistor is to limit the current trying to be sourced from the Arduino into the gate of the MOSFET - steady state of a MOSFET gate requires no current, but it is also a capacitor and turn on/off creates a surge trying to charge/discharge the gate capacitor hence the resistor to limit the current. A side effect of the resistor though is to slow down the turn on/off times - at low switching speeds, that is not a big deal but if you are using it at fairly high frequencies with PWM, then it is spending significant time in the linear region which will cause overheating if not on a heat sink.

---

<div class="post-metadata">

**Author:** ![Wawa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/wawa/32/1211303_2.png) [@Wawa](https://forum.arduino.cc/u/Wawa)\
**Post date:** [April 13, 2016, 12:42am UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/8 "2016-04-13T00:42:34Z")

</div>

> gpsmikey:  
> Actually, Wawa meant IRF540

Yes, typo. Corrected.  
Leo..

---

<div class="post-metadata">

**Author:** ![kcoke](https://avatars.discourse-cdn.com/v4/letter/k/ccd318/32.png) [@kcoke](https://forum.arduino.cc/u/kcoke)\
**Post date:** [April 13, 2016, 3:40pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/9 "2016-04-13T15:40:26Z")

</div>

Thank you for the answers.

The LED has an 37v adapter attached to it, I simply want to turn the LED on without burning the Arduino. I have no idea what's the Amp amount in the chain, since I don't have any stickers on the adapter or any identificators. I will take Wawa's advice on the resistor values and hopefully everything will go fine and I'm not gonna burn my little Arduino down. Been stuck with this for the 5th day, drives me crazy!!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [April 13, 2016, 6:25pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/10 "2016-04-13T18:25:36Z")

</div>

Would a modification of Q8 in the diagram with LEDs replacing the motor, eliminating D10 and using his 2N3904 (Vceo = 40V) for Q9 not work? I don't understand R21 from Q9 base to +5V though.

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [April 13, 2016, 6:48pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/11 "2016-04-13T18:48:56Z")

</div>

R21 is for power up disabling of the FET.

Since the OP is using 37v it is outside the range of Vgs max of +-16.  
Perhaps a 12v zener gate to GND (source) could be used but it sounds like the OP has limited components.

If the supply was 12v things would be OK.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [April 13, 2016, 6:57pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/12 "2016-04-13T18:57:37Z")

</div>

TNX for the explanation, please ignore my ignor-ance. 😕

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [April 13, 2016, 7:37pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/13 "2016-04-13T19:37:13Z")

</div>

FYI, you should stop calling the IRF540 a "transistor". It is not a BJT. It is a mosfet. Just as there are NPN and PNP BJT transsistors, there are N-channel and P-channel mosfets. BJT transistors are CURRENT driven , mosfets are voltage driven. A BJT "transistor" requires a base resistor or you will damage the device the first time you power it up (usually). Mosfets do not require base resistors because they are not current driven devices. Sometimes mosfets need a pulldown resistor from the base to GND but this isn't a general rule. I've used many mosfets without Gate pulldown resistors and never had any issues. It sounds like your application would work with N-channel [mosfet](https://www.sparkfun.com/products/10213) to sink the load current. Don't use that part if you need to operate in the linear region though. Choose a different mosfet for something like that. An IRF730A works in the linear region . If you just need a switch then the first part is fine.

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [April 13, 2016, 9:32pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/14 "2016-04-13T21:32:15Z")

</div>

However

> The field-effect transistor (FET) is a transistor that uses an electric field to control the shape and hence the electrical conductivity of a channel of one type of charge carrier in a semiconductor material. FETs are also known as unipolar transistors as they involve single-carrier-type operation.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [April 13, 2016, 10:22pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/15 "2016-04-13T22:22:13Z")

</div>

What can I say ,? I still vote for "Fet".  
Let's just say it isn't the kind of transistor that needs a base resistor.

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [April 13, 2016, 10:54pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/16 "2016-04-13T22:54:50Z")

</div>

But, may need a gate resistor 😉

---

<div class="post-metadata">

**Author:** ![gpsmikey](https://avatars.discourse-cdn.com/v4/letter/g/5daacb/32.png) [@gpsmikey](https://forum.arduino.cc/u/gpsmikey)\
**Post date:** [April 13, 2016, 10:55pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/17 "2016-04-13T22:55:12Z")

</div>

I agree FET (but what does the "T" stand for in the FET???) Tube - that must be it - some sort of vacuum Tube 🙂

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [April 13, 2016, 11:02pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/18 "2016-04-13T23:02:59Z")

</div>

Field Effect Tube :o

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [April 13, 2016, 11:05pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/19 "2016-04-13T23:05:40Z")

</div>

I give up.

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [April 13, 2016, 11:17pm UTC](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256/20 "2016-04-13T23:17:37Z")

</div>

Just having a bit of fun 8)  
Buy you a beer next time we meet.  
.

[Next page](https://forum.arduino.cc/t/using-transistor-as-a-switch/379256.md?page=2)
