I'm starting a project and I don't know what to do. I will be using a MEGA and two motor controllers (see link below). I was wondering how I should ground everything. Is it ok to have everything grounded on to one Arduino pin? I'm confused because the motor driver has a common ground between the battery pack and the Arduino but I thought to ground something together it had do be the same voltage. I don't really understand how grounds should work so some info would be appreciated.
Ground is a "reference" point against which potential (voltage) is measured. It is the return path for electrical current in the circuit. If wired correctly, 5V arduino and 12V motor parts of the circuit ONLY share a common ground connection and some form of correctly assembled "interface" point that prevents the 12V "sourced" current from flowing into the 5V section of the circuit... Commonly, a transistor or special peripheral interface IC is used. So it is not only good to have your Motor power supply ground connected to Arduino ground, it is essential for the 2 differently powered parts of the overall circuit to be able flow current in a circuit and make things happen.
I'm sure others can explain this better than I, but think of it this way. Voltage used to be known as PD- Potential Difference, and to have a difference you have to have two points. So, if we put volts into the motor shield's + and -, then yep that can come out the other side (so to speak) into the motor.
But if we need to control the gate on the shield to let that voltage through, that's where the Arduino comes in. So we "tickle" the components on the shield with an Arduino digital i/o pin, going up and down, off and on, at the behest of the code in the sketch. Easy to connect a wire, which switches between 0 and 5v under our control) from say Pin9 on the Arduino to one of the control inputs on the shield. BUT..... that wire's 5v is only known as 5v to the Arduino, since it's 5v wrt to the Arduino's ground: its 0v.
It has no meaning in volts to the shield: there's only one wire. So, we need to hook the Arduino 0v to the shield / motor 0v so that the 5v which the Arduino knows as 5v, is also seen as 5v by the shield.
Thank you! Those explanations helped me understand a little better. So from what i'm understanding it's ok to hook all the grounds used in my project to one ground pin on the Arduino. I just want to make sure before I power everything up because I really don't what to lose any parts!
Also, I forgot to mention that each motor driver will be using their own battery pack. So what I plan on doing is running both the grounds of the battery back together and one pin coming from the ground on the Arduino. Then from the connection I will have two wires, one for each ground connection on the motor driver.
The body of your car is a ground... one side of the battery goes to the body, and the other side goes to the components in various wires, then the other side of those components is connected to the body to complete the circuit.
But there might be a few "quirks" that others should maybe comment on. I do recall posts about separating the ground connections physically, albeit that they are electrically the same.
While its usually considered to be a better practice to to really have 1 common ground connection point in a circuit, you can consider ANY pin marked GND (ground) on the Arduino as equivalent place to connect grounds.
Someone else may want to discuss "ground loops" or what happens when there is actually a small potential difference between things marked "ground" in a circuit, but I feel that is out of scope for this question.
Not the aviation one though, please. That's where while landing a fixed wing aircraft with the 3rd wheel at the back (the "conventional" or "taildragger" configuration) where the centre of gravity is behind the front wheels, any inadvertant side force on the wheels causes an uncomfortable spin... Since the outside wing is going faster than the other one, it flies and the inside one digs in...