complete a circuit

hi guys .

i need to the code in the arduino to close and open a switch during certain parts of the code,

my plan is to use a digital out, connect it to the pin of the switch that goes to ground when pressed, then when i send the pin LOW it should act like its been grounded,

the arduino and the external board can share ground im sure,

question ,
is this safe or am i going to send showers of sparks everywhere?

if its not safe, how can i safely do it using normal components found in a parts bin ?

i need the solution to be cheap because i may need to integrate two ro three switch controls, and dont want to pay tons for each ,

thanks in advance

What holds the pin hi normally that you want to ground?
If you don't know: Safest way would be to use a transistor to pull the pin low.
Arduino output pin to 270 ohm resistor to base of NPN transistor, emitter to Gnd, collector to the switch pin.

Connect all grounds in common.
Or use an optoisolator if the grounds must be separated.

The Opto is the Ideal solution... 2 resistors 1 opto, some wire = Problem solved @3.00 for 1 input and about $1.00 ea for expansion BTW a P2504 is a 4 section opto that is REAL easy to use... P2501 2 - 4 for 1, 2. 4 Channel all in one small package P2504 is a 16 pin package and is available in Small Outline (SO) SMT packages

Doc

What voltage and current are you wanting to switch? AC or DC?

if i can find a cheap opto then i will go with that,

but i have a ton of old transistors kicking about here, it would be good to use them,

the switch is just a push to make switch, as far as im aware it isnt controlling any high amps or voltage,

i may want to control five switches in total in the future, so the cheaper the solution the better, i will check out the recomendations later,

thanks,