Added PWM control and infinite loop