Working code to initialize and run motor