Been a while since i have posted back, but i have done it
the motor switches off when motion is detected