Go Down

Topic: Input/Output read/write without using Ground or Power/Source possible? (Read 735 times) previous topic - next topic

privateRob

Hi everybody!

I have a very basic (and perhaps very stupid) question about connecting two digital pins (Output and Input) without using ground or 5V/3.3V output.

So, the simplest example I can think of, is Digital Pin 9 is connected to a push button which is connected to a resistor(10kOhm) which is connected to Pin 8.

An ASCII drawing would look like this:
D9 - PushButton - Resistor(10kOhm) - D8

D8 is a digital input, D9 a digital output.

In all tutorials and examples, the guys are using the Ground or the 5V/3.3V output.
I have read in the documentation, that, if a pin is declared as output, it provides ~5V.
My assumption is, that if I declare a pin as input, it is also grounded.
Right?

And therefore my circuit diagram should be correct. :)
But is it really correct or do I have to connect a pin to the power source or the ground additionally (and if so, why?)?

thx!

DVDdoug

Yes! That can work.  (You don't need the resistor.)

The input & output pins both share a common ground (which is a reference point).   So, if you connect them together, they both have the same voltage, referenced to the same ground.   

Now... If you had two different Arduinos and they each were powered by separate batteries with no common ground between them, connecting the output from one Arduino to the input of another Arduino would not work. 

A voltage needs a reference or a "potential difference", or the voltage needs to be "across something" to get current flow.   With no other connection, the "input" Ardino wouldn't "see" a 5V "difference" between the input pin and its ground.

michael_x


My assumption is, that if I declare a pin as input, it is also grounded.

My assumption is, it isn't grounded.

If you deactivate the input pullup, and your button is open, the input might catch any noise via the wire to the open button.
Test it with a rather distant button and a busy power line in parallel. Connect the input wire from the open button to an analog input and see which random voltage you can measure.

If you activate the pullup resistor for the input, it's stable HIGH when the button is open, and the button can make a connection to GND or to a LOW output. A HIGH output would work as a "disable the button" function, and keep the input HIGH.

Quote
You don't need the resistor
: Agreed

Grumpy_Mike

Quote
question about connecting two digital pins (Output and Input)

This begs the question as to why on earth you would want to do this!

If you have an output your code knows what it was set at so there is no need to read this back through an input. You can even read back the output latch by reading the output pin. So there are two reasons why you would never want to do this.

privateRob

First, thank you guys for the clear and very detailed replies. They are really easy to understand, also for a beginner like me.

Quote
You don't need the resistor

In all tutorials the guys are using a resister (10kOhm) against electric noise.

Quote
My assumption is, it isn't grounded.

Ah, i didn't know, that you also can write to an input pin. But now I do :)

@Grumpy_Mike
So, you also can read the output pin...

Why do I have to declare a pin as output or input at all?
Because you can read and write to an input and output pin... :|

privateRob


Why do I have to declare a pin as output or input at all?
Because you can read and write to an input and output pin... :|


Quote
Note that the pullup resistors provide enough current to dimly light an LED

Sy, found the answer by myself :. . It doesn't provide the "full" current...

Grumpy_Mike

Quote
In all tutorials the guys are using a resister (10kOhm) against electric noise.

They might say that but they would be wrong, it makes the noise problem worst not better.

Quote
It doesn't provide the "full" current...

A bit over simplistic, it actually enables the output drivers. 

Go Up