# Beginner Question - help with circuit

Image: http://imgur.com/UJcb3GC

Hello so i should connect the circuit as the image in the link - very basic.
The one thing I wonder is why does the switch have to be connected to the ground?

Why can't we only have the Green cable that is connected to port 2? the the current will go from + -> switch -> green cable to input port 2 -> and it will switch from LOW to HIGH and send out current from the outputs 3,4 and 5?

Hi,
You have the ‘pull’ the port High or Lw… not leaving it “floating” which is undefined.

It’s hard to tell about your circuit from photo; a “schematic diagram” would make the situation clear.

The microcontroller inputs sense voltage, not current. Furthermore, they are high impedance inputs; very little current flows into or out of them.

If you do not force the voltage to some value by attaching a circuit to it, the voltage will naturally settle on a value based on it's internal biasing. There is no guarantee that that value will be LOW. There's no guarantee that it will be HIGH either. You're not supposed to use an input unconnected like that.

Because the input is high-impedance, when it is unconnected it takes very little energy to change it from LOW to HIGH. This energy can come from any of a number of unpredictable sources, such as radio waves, static electricity, or capacitive coupling from other, nearby circuits. An unconnected input is highly unstable.

marine_hm:
This is probably the worst explanation ever...

It's definitely a finalist for that category.

Jiggy-Ninja:
If you do not force the voltage to some value by attaching a circuit to it, the voltage will naturally settle on a value based on it's internal biasing.

There is no internal biasing, the pin is completely isolated(*) when its an input, so its voltage depends on
nearby conductors and stray electric fields as much as anything.

(*) Unless you take it below 0V or above the supply, in which case the protection diodes cease to be
reverse-biased and start to conduct. CMOS circuitry is based on MOSFETs (tiny tiny ones) which have
insulated gates - then sense voltage through an insulating layer of silicon dioxide (like glass).

Jiggy-Ninja:
It's definitely a finalist for that category.

People like myself (This is just a hobby for me) are looking for help that makes sense to them but need accurate information. My original post was deleted due to being inaccurate.

marine_hm:
that input(sensor) pin will sense current

No, it senses voltage.

marine_hm:
and make a decision as to what it last "heard" on or off.

I don't even not what this is supposed to mean.

marine_hm:
The LAST electron; was it a 0 or 1?

Electrons are not 1 or 0.

marine_hm:
ELECTRONS. Static has electrons,

Static doesn't have electrons. An accumulation OR LACK of electrons on a surface causes a static electric field. Such accumulations are usually formed by different work function when two insulators are rubbed against each other.

marine_hm:
our bodies give off electrons. So if you want it to read 0, then it must be tied to ground when no voltage is applied(pulled to ground).

You ARE applying a voltage - 0V to it, when you pull it to ground.

marine_hm:
Otherwise it is a floating input and will continue reading/sensing any floating electrons that might happen to be near the input wire.

While you probably CAN charge it via static charge (you are basically filling a tiny capacitor), electrons that are floating around in the air are not the problem, but rather electromagnetic waves. The pin than functions as an antenna. So it is rather photons than electrons that cause anything here.

marine_hm:
This is probably the worst explanation ever...

That might be possible. Most of it is wrong.

MarkT:
There is no internal biasing, the pin is completely isolated(*) when its an input, so its voltage depends on
nearby conductors and stray electric fields as much as anything.

(*) Unless you take it below 0V or above the supply, in which case the protection diodes cease to be
reverse-biased and start to conduct. CMOS circuitry is based on MOSFETs (tiny tiny ones) which have
insulated gates - then sense voltage through an insulating layer of silicon dioxide (like glass).

Incorrect. The internal circuitry of a GPIO pin is quite complicated.

On INPUT mode, the transistors used to tri-state the output buffer and turn off the pullup resistor are not perfect. They will have leakage currents that provide a bias to the input buffer. The balance of those leakages will be very unpredictable though, because they are not designed to be used that way, they are a flaw.

This is all at a much lower level than most people usually need to get to though. The biasing force is so weak that it is easily overwhelmed by an external circuit or environmental influence. The vat majority of the time, it’s good enough to just treat the input as an open circuit that cannot sink or source any current.

But when the switch is open no current will go thorugh the circuit as it is not a clsoed circuit so then the input pin 2 will read low.

Then when you close the switch the circuit will be closed and then it will be voltage on pin 2. So if the wire (or the input 2 pin) that is connected to input 2 would have capacitive pickup why would the resistor take away this capacitive pickup?

Like, what would happen if I just removed the resistor (and not adding a wire to the ground, so it is just 5 volt connected to the switch then a wire to input pin 2 and we have no emi or such?)

xefyros:
Like, what would happen if I just removed the resistor (and not adding a wire to the ground, so it is just 5 volt connected to the switch then a wire to input pin 2 and we have no emi or such?)

When the switch is closed, you'd have 5V, but when you disconnect the switch, the input would be floating. This means there would be some voltage on the pin, but it is small, uncontrollable, unstable, unpredictable, and just bad in general.

Never leave inputs floating.

xefyros:
Then when you close the switch the circuit will be closed and then it will be voltage on pin 2. So if the wire (or the input 2 pin) that is connected to input 2 would have capacitive pickup why would the resistor take away this capacitive pickup?

What is capacitive pick-up and what does it have to do with this (very) simple circuit?