I'm trying to build a simple system to turn a water pump every 24 hours for 10-20 seconds. I have 5V pump. When I connect it to 5V, GND it works but when I connect it to pin 12 (or any other digital pin) and GND it does not work. Here's my sample sketch:

int led = 12;

void setup() {                
  pinMode(led, OUTPUT);     

void loop() {
  digitalWrite(led, HIGH);

What am I doing wrong?

  • 1
    \$\begingroup\$ Maybe you want to post a schematic? Specs for the pump would be helpful. At least a picture for your setup. \$\endgroup\$ – angelatlarge Apr 5 '13 at 19:03
  • 1
    \$\begingroup\$ I don't know Arduino, but wouldn't this be a max. current issue? I suspect the Arduino doesn't like it when you're drawing too much current from its pins. Perhaps you should use a transistor as a switch. Also, can you check if the port is high? \$\endgroup\$ – user17592 Apr 5 '13 at 19:15
  • \$\begingroup\$ @AnonymousPenguin Considering this piece of code, it would be even more efficient to simply connect the LED pin to VCC and ditch the MCU. \$\endgroup\$ – Dmitry Grigoryev Jul 4 '17 at 10:19
  • \$\begingroup\$ @AnonymousPenguin And what exactly is wrong with the code which keeps updating the pin at each iteration? On the contrary, not knowing the current pin state allows you to save RAM since you have one less variable. \$\endgroup\$ – Dmitry Grigoryev Jul 4 '17 at 12:39

The motor almost certainly needs more "drive" current than what the IO pin can supply. An output pin might supply (say) 40mA but the motor might need 1A or 2A. The IO pin can't provide the current so the motor sits there doing nothing.

Think of it like water pressure and feeding water through a really small pipe (say 2mm diameter). If the flow rate demand is low it'll work fine but if you want to fill your tub then forget it. Get bigger pipes - the output pin has only got little pipes.

What you need is a transistor that reacts to the lightweight IO line and switches a heavy-duty power-line to your motor. Recently i did this: -

enter image description here

It is a circuit that takes an IO pin from a micro and uses a couple of transistors to switch a battery (5.5V) to a load (motor). It can run from 5V of course.

  • \$\begingroup\$ Thank you for your answer. What can I do to make it working using Arduino? \$\endgroup\$ – keepkimi Apr 5 '13 at 19:06
  • \$\begingroup\$ @keepkimi - check the circuit I added - this should help but without knowledge of the motor current you can't theoretically pick the P-channel FET. Do you know what rating the motor is? \$\endgroup\$ – Andy aka Apr 5 '13 at 19:10
  • \$\begingroup\$ @angelatlarge if you mean it could be really high pressure then I agree. \$\endgroup\$ – Andy aka Apr 5 '13 at 19:11
  • \$\begingroup\$ @Andyaka Sorry for being unclear. I would think that some tiny pumps (with tiny motors) can run on 40mA. \$\endgroup\$ – angelatlarge Apr 5 '13 at 19:17
  • \$\begingroup\$ @angelatlarge There are some neat Faulhaber Series 1506 motors, that work at 10 mA no-load, 20 mA stall. I'm sure a pump could be made using those. \$\endgroup\$ – Anindo Ghosh Apr 5 '13 at 19:42

I think Andy aka's circuit is exactly right, but depending on your motor, you may get away with something a bit simpler, something like this:


simulate this circuit – Schematic created using CircuitLab

If your motor needs something like 100mA you can use a small-signal general purpose NPN transistor instead of a Darlington as in the circuit above, something like BC546/547. The characteristic to look for is peak collector current: that will tell you how much of a load the transistor can drive

The diode across the motor is a snubber/flyback diode, there to protect your circuitry against harmful voltage spikes that could be generated by the motor in your pump when its is shut down. According to Andy aka (see comment below) you'll need it regardless, so in the end this might not be simpler than his circuit.

To be clear, one advantage of Andy Aka's circuit is that it is designed for any motor voltage, whereas the circuit here relies on your Arduino and the motor running off the same V source.

  • \$\begingroup\$ yup the flyback diode is a must for any transistor switch on a dc motor \$\endgroup\$ – Andy aka Apr 5 '13 at 22:58
  • \$\begingroup\$ @Andyaka: Thanks. I wasn't sure since BC546 has C->B 70V max, I'll edit that in. \$\endgroup\$ – angelatlarge Apr 5 '13 at 23:04
  • \$\begingroup\$ The motor's a coil and it will likely produce bigger than 60V if open circuited. Generally the self-capacitance of the collecter and wires can limit but i wouldn't take the risk. \$\endgroup\$ – Andy aka Apr 5 '13 at 23:07

I tried the Angelatlarge's circuit and it works fine. Q1 - TIP142 (max current 10A). Arduino out is any digital out pin (pin 9 in my case). Here is a small sketch, it turn pump on for 10 secounds then turn it off for 10 seconds.

int pin_out = 9;

void setup()
  pinMode(pin_out,OUTPUT);      //set pin no. 9 as output.

void loop(){
  digitalWrite(pin_out,HIGH);   //set pin high
  delay(10000);                //wait for 10 sec
  digitalWrite(pin_out,LOW);   //set pin low  
  delay(10000);                //wait for 10 sec again

Also, here is link how to add RTC to Arduino. I think its much comfortable to manage timer. https://www.circuitlab.com/circuit/76t3nk/arduino-basics-ds1307-real-time-clock-module/

  • 1
    \$\begingroup\$ I've just formatted the code, you can select code and press the code sample button to do it. I assume by 2nd scheme you mean the circuit posted by angelatlarge? If so it might be worth editing to include that information because the order of posts on Stack Exchange can change so it might not always be 2nd. \$\endgroup\$ – PeterJ Mar 30 '14 at 6:44
  • \$\begingroup\$ Thank you for correction, PeterJ, i improve an answer as you suggested! \$\endgroup\$ – SPhoenix Mar 31 '14 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.