hi,
ususaly to do that you have to use an op-amp (operational amplifier)
or if there is some mechanical motion in your device, there are special switches that will close the circuit(let the current pass in a certain direction) if pressed or released.
i did something kind of similar (if i understand what you mean), listen:
i made a device that when a light beam is cutten from a photo-cell (light sensor) a LED will glow. i made this using an op-amp that will invert the current pathing through the LED. (switching the inverting and non-inverting positions so i get the results needed).
if you need more help on op-amps, tell me.