An apparatus for controlling the brightness of one or more light emitting diodes, the apparatus comprising: a sensing circuit to sense a dimming level of a dimmer, wherein the sensing circuit includes a capacitive element to integrate a waveform based on the dimmer output; a circuit to provide a signal to a microprocessor indicative of whether the dimmer is conducting; a drive circuit to drive the one or more light emitting diodes; a snubber circuit to absorb energy generated by ringing of an inductive element in the dimmer, wherein whether the snubber circuit is on or off is controlled by the microprocessor; a power factor correction circuit for coupling between an output of the dimmer and the drive circuit, the microprocessor to receive from the sensing circuit a signal indicative of the dimming level, wherein the microprocessor is arranged to generate a PWM waveform and to provide the PWM waveform to the drive circuit, wherein the microprocessor is further arranged to control whether the snubber circuit is on or off based on the signal indicative of whether the dimmer is conducting, and wherein the microprocessor is arranged to receive a signal from the power factor correction circuit indicative of whether the power factor correction circuit is on or off, wherein, if the signal from the power factor correction circuit indicates that the power factor correction circuit is on, the microprocessor generates a PWM waveform having a duty cycle in accordance with the signal from the sensing circuit indicative of the dimming level and provides the PWM waveform to the drive circuit, and wherein, if the signal from the power factor correction circuit indicates that the power factor correction circuit is off, the microprocessor ignores the current value of the signal from the sensing circuit and generates the PWM waveform having the same duty cycle as just prior to receiving the signal indicating that the power factor correction circuit is off. a sensing circuit to sense a dimming level of a dimmer, wherein the sensing circuit includes a capacitive element to integrate a waveform based on the dimmer output; a circuit to provide a signal to a microprocessor indicative of whether the dimmer is conducting; a drive circuit to drive the one or more light emitting diodes; a snubber circuit to absorb energy generated by ringing of an inductive element in the dimmer, wherein whether the snubber circuit is on or off is controlled by the microprocessor; a power factor correction circuit for coupling between an output of the dimmer and the drive circuit, the microprocessor to receive from the sensing circuit a signal indicative of the dimming level, wherein the microprocessor is arranged to generate a PWM waveform and to provide the PWM waveform to the drive circuit, wherein the microprocessor is further arranged to control whether the snubber circuit is on or off based on the signal indicative of whether the dimmer is conducting, and wherein the microprocessor is arranged to receive a signal from the power factor correction circuit indicative of whether the power factor correction circuit is on or off, wherein, if the signal from the power factor correction circuit indicates that the power factor correction circuit is on, the microprocessor generates a PWM waveform having a duty cycle in accordance with the signal from the sensing circuit indicative of the dimming level and provides the PWM waveform to the drive circuit, and wherein, if the signal from the power factor correction circuit indicates that the power factor correction circuit is off, the microprocessor ignores the current value of the signal from the sensing circuit and generates the PWM waveform having the same duty cycle as just prior to receiving the signal indicating that the power factor correction circuit is off.