5v rellay.

Hello ardiuno comunity!, or whatever...

I have a little problem with a 5v relay connected to an arduino digital pin. The relay is conected in one side to my arduino and on the other one to a "motor speed controller". The speed controller has a "stop switch" that just stops the motor if you joint a pair of pins, so the motor stops when the contacts of the relay move, and that happens when my arduino pin is on high, and that's pretty much all.

Well the problem is that it just don't always work, I don't know if it stops working when my arduino is warm, or what, I just don't know what can be, can you help me with this? do you know any alternative solution?

Ah forgot to say that when I use the 5v pin instead of a digital one on high, it works perfectly, and always, so my theory is that the current of digital pins is kind of variable....

Thank you.

If you are powering the relay from the Arduino 5 volt line, don’t.
Use an external power supply and a transistor to power it.
Make sure you have a kick back diode across the relays coil.
Show us your complete sketch, attach it with code tags use the </> icon in the posting menu.
Show us a schematic.

LarryD:
Use an external power supply and a transistor to power it.

Like this

The absolute maximum current for a pin is 40mA, you have probably exceeded that. This could
mean the pin is damaged now.

It is essential that when driving a relay you prevent inductive voltage spikes (using a free wheel
diode or snubber circuit). If you omit this you typical fry the transistor or IC completely.

There is a difference between a logic signal (low power, fragile, very fast) and power (high
current, robust, speed not such an issue)

If you want to control power with a logic signal you must boost the signal with something like
a transistor, MOSFET, opamp, buffer chip.