I'm working on piece of software for Raspberry Pi and I'm writing an integration test. One of the cases requires that I'm able to read a state of one pin on another (basically if one output pin is high – another input pin should also be high, and vice-versa).
What's the safest way to connect one pin to another so that:
a) Regardless of software settings (Pin is out/in, high or low), there's never a dangerous short.
b) The state of the IN pin is never "floating" (which is the reason for using pull-downs/pull-ups from what I understood)
simulate this circuit – Schematic created using CircuitLab
Basically is R2 needed?
Best Answer
You connect pin b "Input" to a pull up or pull down to force a known state incase pin A "output" is in a floating state. You connect pin a with pin b with a high ohm resistor of 10k~100k ohm resistor to prevent a high current flow if pin a and b are both accidently outputs with different levels. That's to prevent a high to low short.
As most systems can deal with the temporary floating pin, just the precautionary resistor between pin a and b is needed. A pull down/up pin can result in a unnecessary battery drain.