How to make a DC motor act as some sort of switch

hammy:
Use a relay

? ? ?

...R