DC motor control in Python