Relatively new to electronics so don’t know all of the terminology, so please excuse me if I express things incorrectly. I have a fan remote that I would like to control using a Raspberry Pi (photo below). The buttons work by completing a circuit when pushed. I have been able to simulate a press by touching the positive and negative sides of the button with a copper wire.
Based on this I had the following idea: solder the collector of a transistor to the positive side of the button, the emitter to the negative side, and the base to a GPIO pin on the Raspberry Pi. This way, output from the GPIO would open the transistor, allowing the electricity to flow from the positive side of the button through the collector, out the emitter into the negative side, effectively bypassing the button and simulating a press.
Would this work? If so, what kind of transistor should I use and do I need a resistor between the GPIO and the base?
If it wouldn't work, why not?