Beaglebone Black PWM Driver for 12VDC 1.05A Motor | Drive from Positive Side
You can use a P channel mosfet to control the DC motor from the positive side: -



You've got to be careful though if you are using a common ground for both motor andf sensor - you could get false triggers in the sensor if sharing a common wire that is too long/ too flimsy.