How to digitally control the brightness of 16x2 LCD - Page 1
Forum section: electronics / beginners

author: MrOmnos
author_rank: Frequent Contributor
timestamp: August 10, 2016, 12:28:18 pm
content: Hi, is it possible to digitally control the brightness of 16X2 LCD. I have searched all over my workshop, I don't have a pot laying around. So, I was thinking If I could use Arduino itself to control the brightness of the LCD. PWM? How do I do it?

author: JPortici
author_rank: Super Contributor
timestamp: August 10, 2016, 12:31:14 pm
content: brightness or contrast? pwm in any case but for contrast it might get tricky

author: MrOmnos
author_rank: Frequent Contributor
timestamp: August 10, 2016, 12:35:06 pm
content: Quote from: JPortici on August 10, 2016, 12:31:14 pmSorry, I meant contrast!!

author: JPortici
author_rank: Super Contributor
timestamp: August 10, 2016, 12:41:48 pm
content: i think you could be able to do it with filtered pwm, the pwm source must be able to sink currentgoogle seems to confirm

author: rob77
author_rank: Super Contributor
timestamp: August 10, 2016, 01:11:58 pm
content: filtered PWM would work... but the question is how will you adjust the contrast in software with user controls (buttons, encoder) if you don't see the text on the LCD because of wrong contrast setting ?every piece of those cheap 16x2 displays from china is different (that's my experience at least), there is no universal contrast setting for them - so you can't use a pre-set value in software.the best way is a multi-turn trimpot (cheap one from china is more than good enough) and set the contrast for every piece individually.if you really don't have a trimpot around and you need it for a one-off then try different values of fixed resistors to make the right voltage divider for the contrast, the contrast is not drifting on those LCDs (at least not noticeably) so the fixed divider is ok.

author: batteksystem
author_rank: Regular Contributor
timestamp: August 10, 2016, 01:22:14 pm
content: Another way you could probably use a digital potentimeter, microchip has a tons of these with lots of selection, fairly easy to use (I believe it is controlled by I2C) but hell expensive.

author: madires
author_rank: Super Contributor
timestamp: August 10, 2016, 01:54:08 pm
content: Quote from: rob77 on August 10, 2016, 01:11:58 pmI can confirm that from my experience with the TransistorTester project. Several graphic LCD controllers set the contrast by software and it's no easy to find a suitable default value for the contrast. Still there are several users which got problems with the display after upgrading the firmware, because their display requires some uncommonly low or high contrast value. And some screw up the contrast while adjusting it in the contrast setting function. Therefore I've added a special reset mode selectable while powering on.

author: linux-works
author_rank: Super Contributor
timestamp: August 10, 2016, 02:06:18 pm
content: pwm for brightness, digital pot for contrast.

author: MrOmnos
author_rank: Frequent Contributor
timestamp: August 10, 2016, 04:23:16 pm
content: Quote from: rob77 on August 10, 2016, 01:11:58 pmI made a voltage divider using two 4.7k resistors and connected the contrast pin to it. I had to play around with few resistor values to get the result I wanted. 4.7k seems to be the sweet spot for all 4 LCDs I have. I think fixing the contrast in hardware is a better idea for any LCD project. Trim pot is just too much hassle and no one is going to use it anyway. Thanks everyone!!

author: danadak
author_rank: Super Contributor
timestamp: August 10, 2016, 08:02:47 pm
content: I used a PWM on a PSOC UP to control contrast on a 16 x 2 and 20 x 4.In code when part started up it output a standard value on PWM which equated to V.If the user could not see display he started it up coupled with a button push. Thattriggered in code a routine that slew the PWM value from min to max, slowly, and whenLCD screen came into view able contrast he/she could press button again to freeze at thatvalue.Same routine was used when system was setup in a utility and the optimal user perceivedcontrast value was saved for future user startup.Don't forget to LP Filter the pwm out to get DC for contrast pin. See attached design considerations.Regards, Dana.

author: macboy
author_rank: Super Contributor
timestamp: August 11, 2016, 04:59:50 pm
content: The contrast pin virtually never needs a pot, so using one will just waste power. For these HD44780 type modules, all that is required in my experience is a resistor to ground. Often a value of zero works, i.e. connect the contrast pin directly to ground. Otherwise just play with the value until you find the one the works for your module. If you really want/need end user adjustability, then you could try PWM.

author: tooki
author_rank: Super Contributor
timestamp: August 14, 2016, 02:38:11 pm
content: I've used filtered PWM to control contrast, works fine. Doesn't solve the issue of variability between units of course.What's a real pain in the ass are the LCD modules (big ones, in my experience) whose contrast adjustment range spans both positive and negative voltages!

author: dannyf
author_rank: Super Contributor
timestamp: August 14, 2016, 03:35:16 pm
content: QuoteThe simplest would be to use a digital pot.Alternatively, use a pulse generator (pwm for example) + charge pump (diodes + capacitor).