I have recently brought an arduino nano. It has only two ground pins but I needed three for my project. Is there a way to use a digital or analog pin as ground pin? Please show me how to do it

  • 4
    ground is only one. connect every ground wire to one ground pin – Juraj Mar 24 '18 at 14:55
  • 3
    Careful with using GPIOs as GND sinks.. An I/O pin can sink only so much current. For a GPIO bank, 100mA max, one pin recommended 20mA (playground.arduino.cc/Main/ArduinoPinCurrentLimitations). I would connect directly to the main GND (from the power supply). Solder a few more wires if you have to. – Maximilian Gerhardt Mar 24 '18 at 15:10

There is no need to separate grounds, you can connect all grounds together. In fact they are connected together on the board itself.


If your project is on a breadboard, you can use one of the "rails", typically the blue longways row at either edge of the breadboard, to collect all of the necessary grounds, and wire that to one Ground pin on the Arduino.

If you're building a printed circuit board to connect to the Arduino, do the same thing - collect all of the PCB grounds together and wire that to one Arduino Ground pin.

If you're using a manufactured shield, you may have to get creative about collecting your grounds. A tiny breadboard is one way. Another is to solder a number of wires together in star-formation, insulate the solder joint with tape or shrink-tube, and connect one of the star's points to the Arduino ground.

If some of your devices needing grounds are low-current devices such as LEDs, you could set an unused pin to OUTPUT mode, and LOW, and use it as a ground, but the device must not be passing more current than an Arduino pin driver can sink. From Atmel's data sheet for the AtMega328p (used in the Uno):

Although each I/O port can sink 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 IOL, for ports C0 - C5, ADC7, ADC6 should not exceed 100mA.

2] The sum of all IOL, for ports B0 - B5, D5 - D7, XTAL1, XTAL2 should not exceed 100mA.

3] The sum of all IOL, for ports D0 - D4, RESET should not exceed 100mA.

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.


You can just try converting two digital pins as 5V VCC and ground. This will be useful when we use multiple sensors.

#define VCC2  5 // define pin 5 or any other digial pin here as VCC2
#define GND2  2 // define pin 2 or any other digital pin as Ground 2

void setup() {
  pinMode(VCC2,OUTPUT);//define a digital pin as output
  digitalWrite(VCC2, HIGH);// set the above pin as HIGH so it acts as 5V

  pinMode(GND2,OUTPUT);//define a digital pin as output
  digitalWrite(GND2, LOW);// set the above pin as LOW so it acts as Ground  

void loop() {
  • I'm not sure I'd recommend this, but if you're going to do it you should know that it will have very limited current available, which will depend heavily on the Arduino involved, or rather its MCU. You might allowed up to 40mA, but also perhaps only 4mA. And that your new "VCC" will drift toward ground as you draw more current. Likewise with "GND" raising toward VCC. They may not start as near the board VCC and GND as you like, as they're not intended for this purpose but only to produce logic levels. – timemage Apr 24 at 12:05
  • It can be useful if you need to turn on/off the sensor during operation, but as timemage said, it is not advised. Using a transistor controlled by the Arduino's pin is way better. – Sacha Apr 24 at 14:48

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.