added code for DC motor