Digital pins and grounds

Let me start by saying I have an ardunio mega 2560. I'm really confused about why I only have what appears to be 6 grounds but 43 digital ports and 15 analog. Why do I have so many ports but only 6 grounds? Can I use digital pins as grounds without blowing my arudino up? I feel like I'm missing something really basic but I don't know what.

That was the design choice made. Connect your external grounds together and bring them back to a common point.

A pin can source current to drive an output high, or it can sink current to bring an output low. The pin is capable of ~20-25mA in either direction with the High and Low voltage degrading as current increases (dropping from a High level or rising from a Low level). The pins are not current limited and will smoke themselves if you should try to put more than 40mA thru them/

RevScarecrow: Let me start by saying I have an ardunio mega 2560. I'm really confused about why I only have what appears to be 6 grounds but 43 digital ports and 15 analog. Why do I have so many ports but only 6 grounds? Can I use digital pins as grounds without blowing my arudino up? I feel like I'm missing something really basic but I don't know what.

Humm, never heard that complaint before and I've been around here for awhile. ;) Well a Uno board only has 3 ground pins to support its 14 digital and 6 analog pins. Not sure what your expectations would be, but connector pins are a resource on a space limited board, however there is no reason that several external wires needing to be wired to a arduino ground pin can't be wired together and then attached to a single arduino ground pin. Or as many people do, use a solderless breadboard and wire a single wire from an arduino ground pin to the 'ground bus' on the breadboard where there will be many ground attachment points you can use. There isn't an electrical reason that every digital or analog pin needs to have a dedicated ground return point, an common ground collection point that is then wired to a single arduino ground pin will work. Perhaps if you could explain what you are attempting to wire up to that you need so many ground pins?

As far as using a digital output pin set to low to provide a 'ground return point', yes that is possible, but it would carry the pin's maximum current limit and is not normally done except in some cases where you wish to start or stop current flow under software control.

Lefty

I think the OP is under the impression that each IO pin should have its own ground pin to connect to.

That is not how it works. All the ground pins on the board link to the same lump of metal. You can connect to any place on the board that is part of that lump of metal - the ground pins, the outside of the USB connector, the negative connection of the barrel jack - they are all the same.

You can connect as many wires as you like to one ground pin.

You can always buy a sensor shield for your Arduino Mega. This makes connecting things to the Mega a lot easier. I have a sensor shield for an Uno and Mega: http://www.bajdi.com/?attachment_id=152 Next to every digital/analog pin there is a 5V and GND pin.

RevScarecrow: Let me start by saying I have an ardunio mega 2560. I'm really confused about why I only have what appears to be 6 grounds but 43 digital ports and 15 analog. Why do I have so many ports but only 6 grounds?

Simple: Adding 43 more connectors would make it much bigger and more expensive.

RevScarecrow: Can I use digital pins as grounds without blowing my arudino up? I feel like I'm missing something really basic but I don't know what.

You can connect multiple things to each ground pin.

Don't use digital pins as grounds. Sending current through a transistor is NOT the same as connecting it to ground (it's more like sending it through a resistor).

fungus: Don't use digital pins as grounds. Sending current through a transistor is NOT the same as connecting it to ground (it's more like sending it through a resistor).

You should qualify that with "Sending current through a MOSFET transistor...", as a BJT is more like a diode than a resistor.

majenko:

fungus: Don't use digital pins as grounds. Sending current through a transistor is NOT the same as connecting it to ground (it's more like sending it through a resistor).

You should qualify that with "Sending current through a MOSFET transistor...", as a BJT is more like a diode than a resistor.

I wrote that because when you're using it as a switch a fully open BJT is more like a resistor then a fully open MOSFET is (ie. the BJT will have a much bigger voltage drop across it than the MOSFET).

PS: I'm assuming they're BJTs inside the chip...

fungus:

majenko:

fungus: Don't use digital pins as grounds. Sending current through a transistor is NOT the same as connecting it to ground (it's more like sending it through a resistor).

You should qualify that with "Sending current through a MOSFET transistor...", as a BJT is more like a diode than a resistor.

I wrote that because when you're using it as a switch a fully open BJT is more like a resistor then a fully open MOSFET is (ie. the BJT will have a much bigger voltage drop across it than the MOSFET).

PS: I'm assuming they're BJTs inside the chip...

"Never assume anything as it makes an Ass out if U and Me" ;)

They're CMOS chips, so they use MOSFETs. It's rare for BJTs to be in logic / MCU chips these days.

A MOSFET is like a variable resistor, with the resistance being set by the gate. A BJT is a fixed voltage drop with little or no resistance - just like a diode.

majenko: "Never assume anything as it makes an Ass out if U and Me" ;)

They're CMOS chips, so they use MOSFETs. It's rare for BJTs to be in logic / MCU chips these days.

OK...I retract everything I said so far.

fungus:

majenko: "Never assume anything as it makes an Ass out if U and Me" ;)

They're CMOS chips, so they use MOSFETs. It's rare for BJTs to be in logic / MCU chips these days.

OK...I retract everything I said so far.

You don't need to retract everything... It's still the case that you can't (or certainly shouldn't) use digital IO pins as ground. Sinks, yes, but not grounds.

majenko:

fungus: OK...I retract everything I said so far.

You don't need to retract everything... It's still the case that you can't (or certainly shouldn't) use digital IO pins as ground.

Apart from that bit, obviously... connecting to a proper ground pin isn't the same as connecting through a transistor (BJT or MOSFET).

majenko:

fungus:

majenko: "Never assume anything as it makes an Ass out if U and Me" ;)

They're CMOS chips, so they use MOSFETs. It's rare for BJTs to be in logic / MCU chips these days.

OK...I retract everything I said so far.

You don't need to retract everything... It's still the case that you can't (or certainly shouldn't) use digital IO pins as ground. Sinks, yes, but not grounds.

that you can't (or certainly shouldn't) use digital IO pins as ground. Sinks, yes, but not grounds.

Well you make that sound like a physical law which should never be disobeyed. Using a digital output pin as a 'switchable ground' can be useful is several situations I have used in the past. Say for being able to dynamically turn power on and off to a low current sensor, or perhaps to control a low current 5vdc single coil latching relay. It's not standard practice of course, and if used needs to be analyzed carefully, but to imply that it is never to be considered as part of a designers tool kit of methods is somewhat simplistic in my opinion.

Lefty

retrolefty:

that you can't (or certainly shouldn't) use digital IO pins as ground. Sinks, yes, but not grounds.

Well you make that sound like a physical law which should never be disobeyed. Using a digital output pin as a 'switchable ground' can be useful is several situations I have used in the past. Say for being able to dynamically turn power on and off to a low current sensor, or perhaps to control a low current 5vdc single coil latching relay. It's not standard practice of course, and if used needs to be analyzed carefully, but to imply that it is never to be considered as part of a designers tool kit of methods is somewhat simplistic in my opinion.

Charlieplexing does it, too...

fungus:

retrolefty:

that you can't (or certainly shouldn't) use digital IO pins as ground. Sinks, yes, but not grounds.

Well you make that sound like a physical law which should never be disobeyed. Using a digital output pin as a 'switchable ground' can be useful is several situations I have used in the past. Say for being able to dynamically turn power on and off to a low current sensor, or perhaps to control a low current 5vdc single coil latching relay. It's not standard practice of course, and if used needs to be analyzed carefully, but to imply that it is never to be considered as part of a designers tool kit of methods is somewhat simplistic in my opinion.

Charlieplexing does it, too...

Excellent example.