I have a GPIO transistor short circuiting a button on a calculator. I already did the transistor-led projects, but I have a problem:

I believe (correct me if I'm wrong) that when current travels to the base, it must leave somewhere. I would guess that it leaves the emitter or collector (respective to polarity) but I don't know. Anyway, ground needs to be connected to the circuit somehow. How would I do this?

closed as unclear what you're asking by Milliways, Dmitry Grigoryev, Aurora0001, flakeshake, Patrick Cook Dec 21 '18 at 21:55

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • @Fabian I wouldn't, not in in its current form anyway. The OP should draw a schematic first. – Dmitry Grigoryev Dec 12 '18 at 9:44

If I am right it sounds like you are trying to interface your RPi to some external hardware - which in this case is one key on a pocket calculator, however the same principle can apply to other situations e.g. a battery operated remote control to operate some mains equipment which it is not realistic (or safe unless you really, really, really know what you are doing ⚡☠⚡) to connect to directly.

To answer your immediate question the current applied to the base of a junction (or bipolar) transistor flows through the (positively-biased) base-emitter junction where it enables a much larger current to throw across the (reversed-biased) collector-base junction and then both currents pass through the emitter.

What this means though is that - as you have realised - to use a transistor as a switch/controlling element in another circuit there needs to be two connections to that circuit in order for things to function. This is why you will often hear of the requirement to connect the 0 volts or ground connections together of the RPi and the other thing that you wish to control.

However this is only a viable means of getting the RPi to control something if one side of the switch you wish to replace/bypass/override is connected to a fixed voltage - like a power supply or ground line. In reality it is very likely that instead the keypad of something like a calculator has a matrix arrangement where both sides of each switch are connected to a microprocessor and one side (row or column) of the matrix is driven one line at a time high or low whilst all the others are kept in the opposite state and the other side (column or row) is monitored to see which lines go to that state.

In order to connect to this the most straightforward way is to use a relay that is driven by a transistor in the manner I show below in which SW15 represents the one button/switch that you wish to have paralleled by the NO (normally open) contacts of the relay, which when the transistor is switch on briefly with a pulsed high GPIO signal will close as if the button on the calculator was pressed...

U3 is a mock up of the brains in the calculator and shows a few lines connected to a representation of a matrix of buttons (only 16 in this case but it is just a demonstration!) - no power supplies in the calculator are shown because a relay is the one situation where no other connections apart from the two for the contacts are used - this is an arrangement that is known as a volt-free contact because, other than for safety reasons involving high voltage or high current situations, there is no linkage back to the controlling circuit in terms of the voltages in the two parts (coil and contacts) of the relay.


simulate this circuit – Schematic created using CircuitLab

Not the answer you're looking for? Browse other questions tagged or ask your own question.