Well, a mosfet is a type of transistor.
For 100mA, a simple 2N2222A transistor will do. That is not much current, but it is more than an Arduino pin can handle.
You will need a resistor between arduino pin and transistor base pin, say 270 ohm to limit arduino current to ~15mA.
chris8644:
Hey I have read that if your coil current is 100 milliamps or above one should use a mosfet instead of a transistor.
FIrst of all, a MOSFET is a transistor... maybe you mean a BJT.
Most BJTs can do way more than 100ma, even the small ones. They also make big ones with heatsinks for bigger jobs, although if you want to switch 10 amps a MOSFET is probably less trouble.
MOSFETs and old-fashioned BJT transistors have different characteristics. You should choose a type based on what you're actually doing.
Grumpy_Mike:
OK to actually answer the question, I would say the dividing line is about 400 to 500mA when switching over to a FET, but it isnot hard and fast.
That's also the figure I use, when using breadboard or stripboard. For PCB designs I use mosfets below 400mA too - there are lots of inexpensive medium-current mosfets that are only available in SMD packages.
I should have stated a small transistor (2pn2222) vs. mosfet.
The relays can handle up to 10amps but I am only going to draw <1 amp.
So I will use the small transistor and use a smaller resistor between the middle pin and the arduino pin lets say 300 Ohms?
Thanks again !
IF you are going to use a BJT, you size the resistor to (a) limit the current supplied by the Arduino pin and (2) make the current high enough to saturate the transistor.
So, pick a value like 20 milliamps. Safe for the Arduino, and the relay draws 100 milliamps, you need a current gain (beta) of 100/20 or 5.
The 2N2222 current gain is shown as a minimum of 100 at 150 mA Ic, so now we see that 20 milliamps is way more than enough... let's drop Ib down to 10 mA.
So, 5 volts - 0.7 for the base-emitter drop is 4.3 volts. R = 4.3 / 0.010 = 430 ohms. Either 390 or 470 are close, standard values and either one will work.
This is how you figure out the proper base resistor... "dartboard engineering" - saying "well about xxx ohms" is not the way to do it!
Remember, if you use a DARLINGTON BJT, then you have two base-emitter drops, so you calculate with 5 - 1.4, not 5 - 0.7
Disagree about not having a gate resistor.
MOSFETs can have fairly significant input capacitance.
When arduino pin changes state, the capacitance looks like a dead short.
The resistance limits the arduino current until the cap changes state.
5V/35mA = 143 ohm, so 150 ohm resistor would be good choice to use.
Why dose every one think that a Atmega 328p can source and sink 40 mA the datasheet said that's not going to happen the chips VCC and Gnd pins can only source and sink 200 mA now there 23 I/O on that chip do the math 23 times 40
That's almost a 1Amp Now you can sink or source 40 mA on 4 pins max if you go over that your over the max spec for that chip. One pin may even handle 80mA for a short time depending on how big the power bus is in the chip but I wouldn't use that chip for anything that you want to work day to day.
If you want to drive a 2n2222 or a 2n7000 use a resistor that limits the pin output to 10mA.
Why it's 40mA a pin if that was true the VCC would need more pins and so would the gnd and the max would not be
DC Current VCC and GND Pins................................ 200.0 mA
And the first time you drive 320mA out a port see how long you chip can handle that before it shuts down.
This is the Absolute Maximum on a pin that's doesn't mean all 23 can be at that level and is a bad idea to get to thinking you can
DC Current per I/O Pin ............................................... 40.0 mA
There even internal resistance that would limit the output of the pin but to use this is not a good idea for any one that just got started using the Arduino.
But that a whole new story.
Why dose every one think that a Atmega 328p can source and sink 40 mA the datasheet said that's not going to happen the chips VCC and Gnd pins can only source and sink 200 mA now there 23 I/O on that chip do the math 23 times 40
You are miss reading things. This is a limit you should not exceed, it is not a limit that can not be exceeded. It is perfectly possible to exceed these limits only you should not if you want to avoid damage to the chip.
This is the Absolute Maximum on a pin that's doesn't mean all 23 can be at that level and is a bad idea to get to thinking you can
Quote
DC Current per I/O Pin ............................................... 40.0 mA
Read the fourth and fifth word there you didn't read my whole post.
I didn't miss read anything I know for a fact what these chips can do and can't but you here all the time That this chip can sink 40 mA a pin that's a PIN not a port of PINS
So I was letting OP know that he needs to watch that.
the datasheet said that's not going to happen the chips VCC and Gnd pins can only source and sink 200 mA now there 23 I/O on that chip do the math 23 times 40
You probably want to read the datasheet very careful one more time I am reasonably confident that the datasheet did not say what you think it says don't trust my words you can re-read the datasheet to be sure
Absolute Maximum Ratings*
DC Current per I/O Pin ................................................ 40.0mA
DC Current VCC and GND Pins................................. 200.0mA
('328P has two Vcc and two Gnd Pins)
*NOTICE: Stresses beyond those listed under “Absolute Maximum Ratings” may cause permanent damage
to the device. This is a stress rating only and functional operation of the device at these or
other conditions beyond those indicated in the operational sections of this specification is not
implied. Exposure to absolute maximum rating conditions for extended periods may affect
device reliability.
Common DC characteristics TA = -40C to 85C, VCC = 1.8V to 5.5V (unless otherwise noted)
VOL Output Low Voltage(4) IOL = 20 mA, VCC = 5V: 0.9V
VOH Output High Voltage(3) IOH = -20 mA, VCC = 5V: 4.2V
Notes:
“Max” means the highest value where the pin is guaranteed to be read as low
“Min.” means the lowest value where the pin is guaranteed to be read as high
Although each I/O port can source more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady state
conditions (non-transient), the following must be observed:
ATmega48A/PA/88A/PA/168A/PA/328/P:
1] The sum of all IOH, for ports C0 - C5, D0- D4, ADC7, RESET should not exceed 150mA.
2] The sum of all IOH, for ports B0 - B5, D5 - D7, ADC6, XTAL1, XTAL2 should not exceed 150mA.
If IIOH exceeds the test condition, VOH may exceed the related specification.
Pins are not guaranteed to source current greater than the listed test condition.
Although each I/O port can sink more than the test conditions (20 mA at VCC = 5V, 10 mA at VCC = 3V) under steady state
conditions (non-transient), the following must be observed:
ATmega48A/PA/88A/PA/168A/PA/328/P:
1] The sum of all IOL, for ports C0 - C5, ADC7, ADC6 should not exceed 100 mA.
2] The sum of all IOL, for ports B0 - B5, D5 - D7, XTAL1, XTAL2 should not exceed 100 mA.
3] The sum of all IOL, for ports D0 - D4, RESET should not exceed 100 mA.
If IOL exceeds the test condition, VOL may exceed the related specification.
Pins are not guaranteed to sink current greater than the listed test condition.
So: 40mA may be achieved, and output voltage is likely to rise when sinking and to drop when sourcing if more then 20mA is being used.
Clearly, up to 300mA may controlled by the '328 IO pins if the current is spread around.