Added logging messages.
Refactored into a class Pwm().