In the figure we have the way to use an on-off sensor to control a load up to 100 mA. The circuit has an anti-ringing capacitor and the power can be between 3 and 12 V. For larger loads, the 10k resistor can be reduced and instead of the original transistor, a BD135 or TIP31 can be used. The circuit is from the book Robotics, Mechatronics and Artificial Intelligence by Newton C. Braga.