Refactor PWM functionality

Add a new method to set LED brightness.
Refactor PWM, and simplify the code.