Main Site Documentation

PWM control of a 5v LED (LCD backlight)


OK, an interesting one. Well in my view anyway :slight_smile:

Ordinarily, if I was going to control a LED’s intensity I would use PWM.

I have an LCD, and the backlight will not operate on 3v3, so I have to use 5v to illuminate it. That also means can’t directly control it with the Fez’s PWM line.

So it’s pretty simple, if all I want to do is turn it on and off - use a transistor.

But that’s not what I’d like to do. I’d like to be able to dim it as I turn it on and off, so that it ramps up/down the light intensity.

I have done some tests using a BC548 NPN transistor and when I use PWM in a test moving between 0% and 100% with 10% steps, I get flicker at 90% or lower. I’ve tried different PWM frequencies but that didn’t make any difference (and I’m not sure why). I don’t have an oscope to watch the waveform, but I’ve tracked voltage with a DMM and see it changes as expected. I wondered whether the frequency was too much for the transistor, but can’t see anything in the datasheet that talks specifically about switching frequencies - there is mention of mhz, so my paltry 10khz signal should be no problem, it has to be something to do with the LCD’s LED :frowning:

So does anyone have any suggestions on how to achieve that?

edit: I also just put the signal through a level shifting buffer, a 74LS245, and the same flickering is evident - that’s the other reason I reckon it might be something to do with the LCD


What kind of LCD? What kind of backlight? What period and duty cycle are you using on your PWM?


LCD = generic HD44780 4-line text LCD. or similar if I remember correctly, I’ve had it around for ages…

The killer is that I’ve reset the Fez a couple of times, and now things seem to be working as expected, no flicker. I might have had a loose breadboard wire I’ve bumped/adjusted and now it’s working. Perhaps the power off of the LCD has helped. Mmmmmm…