How to control a motor if it is supplied power via an external power supply?