For example, when a push button is pressed. The 5V supply connects to the signal cable, which is attached to Pin 2, for example.
But where does the current ‘sink’ into? Doesn’t it need an explicit ground pin? If it goes right into Pin 2, is that the ground pin in disguise?
Or is the signal pin (pin 2) the one applying the current through the push button..?
In: 0
The input pin is EVENTUALLY connected to ground but not directly. It has to in order to complete the circuit. But no, the signal pin isn’t a disguise for anything. When connected to a 5V it will sink a bit of current (although usually very small).
If you connect a lightbulb in a home. One side goes to live and the other to neutral. It is not very useful to say that the side that is connected to live is a “disguised” neutral. It is connected to the neutral line on the other connection but only after the current passes through the lightbulb.
For the Arduino to properly sense the voltage on the incoming pin and respond to it, the Arduino and the device sending the signal need to have a common ground reference.
The usual way to do this is to have the Arduino and the device connected in such a way that their grounds are tied together, or to link the Arduino’s ground pin to the external device’s ground. Depending on your circuit design and the power limitations, this may or may not be a workable system, but for a push button sending a signal, it should work.
This thread from the Arduino forums may help shed some more light on the issue:
https://forum.arduino.cc/t/connecting-grounds-together-why/64678
The input pins are internally connected to ground pin through a capacitor. That means, that the current flows in/out of pin only then the input level changes, and only for a brief time. The logic level is detected by the charge on the capacitor (it’s not just a capacitor, but a gate of a MOSFET).
If internal pull-up is activated, the pin is also connected to Vcc through a resistor. Connecting such pin to ground will create constant current, but connecting it to 5V won’t.
[Here you can see the internal schematic of the pin connection](https://microchipdeveloper.com/8avr:ioports) (first picture on the page).
Arduino pins can either be set to drive a voltage on a line (output) or be de-coupled from the line (input).
In the latter case, all you’re doing is detecting the voltage on the pin. There’s no circuitry connecting the pin and the rest of the Arduino.
So now let’s use a simple switch. When it’s closed, current doesn’t flow. When it’s open, current flows.
On one side of our switch, we’ll connect to 5V. On the other side of the switch, we’ll connect to ground.
We’ll also need to connect a resistor (otherwise when our switch closes we get ‘infinite’ current). We can put it anywhere in this circuit, but we’ll put it before the switch in this example.
Now, let’s connect the Arduino pin between the resistor and the switch.
When our switch is open, the near side of the switch – including our Arduino pin – is charged up to 5V. Once it hits 5V, it just stays there because it can’t go any higher (it’s only being driven at 5V) and there’s nowhere for the charge to drain.
Now close the switch. Suddenly there *is* somewhere for it to drain – through the switch and to ground. The result is that everything beyond the resistor rapidly falls to ground (0V) while everything before the resistor stays at 5V. Since our Arduino pin is on the far side of the resistor (from the 5V source), it goes to ground.
However, at no point does any current flow *into* the Arduino. There’s no path for it to do so. It just changes the voltage on the pin itself.
Note: I’ve idealized the description here. With real world electronics, enough power would let you arc across the non-conducting gap in the Arduino and blow it up.
Analog inputs are voltage meters and they measure voltage, not current. You don’t need any current to be flowing into/out of the pin, so you don’t need a “complete circuit” with power and ground.
By analagy, imagine a garden hose. It’s turned on at the tap, but ends in a pressure sensor that blocks the end and measures the water pressure. No water is moving, but the sensor can still measure the pressure.
Voltage is electric pressure. Tap, turned on, is 5v source. Sensor is input pin.
Latest Answers