I know that this topic was well discussed in this forum, but I've not found an answer for this question. I've saw this schematic of a relay to control a lamp:
h t t p : / / ptpointnet. yourwebhosting.com/blog/mylamp/ml2_circuito.jpg
The question is, can I use a relay of 5V directly into the Arduino pin ? If I need to use a transistor, where the 5V input to the relay comes from ? If this 5V input to the relay comes from the 5V pin in the Arduino, why do I need a transistor ?
I've read also that the DC current for I/O pin in Arduino is 40 mA. This value is true even when I plug Arduino into a wall wart power suply of 1A let's say ?
And the 5V pin in arduino, what is the max current that I can draw from this pin ? It's the same 40mA ?
Inside the Arduino Chip (the Atmega 168, 328, etc chips) there are transistors that switch current to the I/O pins. These are tiny transistors and are able to safely handle only current levels up to 40 ma. Exceeding the current levels can burn out the internal transistors.
But the discrete external transistors you wire to switch a relay, etc are rated for much higher current levels which, depending on which transistor you choose, can be from a couple hundred ma to amperes.
So the Arduino chip can drive low current loads (say LEDs) directly but higher current loads require the help of external transistors.
The +5V pin on the Arduino boards connect directly to the power supply so the current that it can supply is larger - typically a couple of hundred ma. If you need more current than that you can use an external power supply.
Thank you Roy, when you say that the +5V pin of the Arduino connects directly to the power supply you say that this +5V is regulated by Arduino before, right ? So, if I plug a 12V supply to the jack in Arduino, there still +5V in the +5V Arduino pin, right ?
So it's safe (if I have a DC wall wart power supply of 1A) to draw let's say 300mA from the +5V pin ? And when the Arduino is in the USB, what is the maximum current that I can draw from the +5V pin ?
It's working now, I've used a 12DC to power the relay as the schematic below:
h t t p : //www.instructables. com/id/S58ZMBSFQ2DZ0X1/
I've used the 2N2222 transistor with a 1k resistor in the base and a 12V relay, when the pin of Arduino is HIGH in the base of transistor, the relay "clicks", but it remains on even when I change the Arduino pin state to LOW, it just clicks again when I power it off (the 12DC power supply). What can be the problem ? The transistor should not stop the circuit when I put LOW value into it base ??
So it's safe (if I have a DC wall wart power supply of 1A) to draw let's say 300mA from the +5V pin ?
It depends on the voltage of the wall wart, and on which Arduino you have.
All but a couple of mine have regulators in TO-220 packages that can dissipate a Watt or so with no problem. And I usually run them off 7.5V wall warts if there's much external circuitry attached.
But there are many flavors of Arduino that have regulators in smaller packages that can't dissipate nearly as much heat.
So, if you plug a 12V wall wart into an Arduino with a small surface-mount regulator, and try to draw 300mA, there's a very good chance that the regulator will either go into thermal shutdown, or get cooked.