Software PWM for controlling LEDs