Imagine I have a 5v wire connected to a resistor, a button, an LED, and a pin set to ground. When I press the button the LED goes on.
I want to be able to recreate a circuit like this without the button so that the LED can switch between on and off while the code is running. The catch is that I cannot change the 5v pin from 5v and I cannot change the ground pin to 5v. I need to either be able to change the ground pin to and from a high impedance state or use some sort of replacement for the button that the Arduino can control. Unfortunately it seems that digital pins cannot be switched between input and output while the code is running and I can't figure out any other way to solve this.
The reason I ask: I am trying to wire a PCB designed to be controlled by button presses so that I can control it with Arduino. By default the PCB has one 5v, one ground, and four buttons, depending on what button is pressed one of four things happens. I attached a wire to each button, and if I set one of those wires to ground its just like I pressed the button. But I need to be able to control which button is 'pressed,' and I can't figure out how to do that.