Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want an I/O pin to return current in a circuit, similarly to the function of ground.

Which of these will achieve what I require?

pinMode(pinnumber, OUTPUT)
digitalWrite(pinnumber, LOW)


pinMode(pinnumber, input)
share|improve this question
your second option pinMode(pinnumber,input) is placing the pin in the "third state" of the pin, which is also called "high impedency". It's basically like if the pin was not connected to the circuit, like a ohmmeter does. – zmo Mar 5 '14 at 13:31
"digitWrite"? Don't you mean "digitalWrite"? – Peter Mortensen Mar 6 '14 at 20:23
corrected, thanks for pointing out. – rajat Mar 7 '14 at 6:59
up vote 9 down vote accepted

Your first snippet is the correct solution.


Be careful though, you can only sink up to 6mA or 9mA per pin (as per the documentation ["Input and Output" section], I never tried more). If you need more current, use a transistor (this looks like a good example, you just need to invert the output pin to HIGH).

When the pin is configured as input it is supposed to be high impedance, not what you want.

share|improve this answer
Thanks, the current also comes from the IO pins of Arduino. Therefore, i don't think 40mA limit will be a issue. – rajat Mar 5 '14 at 10:30
@rajat Doing some sort of LED matrix ? Be careful, assuming you plug (for example) a high current LED between two pins (at least without a proper current limiting resistor), you could still damage the chip. Not even mentioning the case where you create a short circuit. – FredP Mar 5 '14 at 10:35
It is a pressure sensor matrix, it has 10 16:1 multiplexers. The current only comes from the Arduino USB cable and no external power supply.Therefore, i don't think high current will be a issue. Can you shed some light on what possibly can cause a short circuit? – rajat Mar 5 '14 at 10:37
@rajat something like that would create a short if pin "1" and "2" are connected : pinMode(pinnumber1,OUTPUT); pinMode(pinnumber2,OUTPUT); digitalWrite(pinnumber1,LOW); digitalWrite(pinnumber2,HIGH); PS : do not try this at home, do not harm innocent arduini, do not sue me, etc... – FredP Mar 5 '14 at 10:43
I was a bit surprised by the 6/9mA number. Turns out you’re correct for the Arduino Due, but for the AVR based Arduinos (Uno, etc), which I suspect are still in the vast majority, that number is more like 40mA. – microtherion Mar 6 '14 at 21:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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