Trying to dim an LCD Backlight

I bought the following:

I2C backpack (YwRobot LCM1602 IIC v1)
LARGE 20x4 LCD (JHD762M5) (http://tinyurl.com/ar99rj2)

It didn't work out of the box, but a little searching led me to this, which works fine:

[SOLVED] SainSmart/YwRobot I2C LCD works well
Arduino Forum

The problem is that I really want to be able to turn down the backlight brightness and I do not seem to be able to do anything more than turn the backlight on and off using "lcd.setBacklight()". Is this a limitation of the I2C, or the LCD (either? neither?)

I do not need to control the brightness via software (I just figured that this would be the simplest solution), and I would prefer not to set up PWM control. I would be happy to just put a pot on it and be done, but when I researched that solution I read that it is not the preferred method, and to use a transistor... I got a bit confused at that point. Can someone please point me in the right direction regarding how to proceed? Is the solution as simple as putting a pot inline at pin 15 or pin 16.

This is a very large display. I measured about 90mA current draw with the screen lit up, so if I do go the PWM route I think that I will need to use a transistor. Right?

Thanks!
MML

It's a LED (array), so the way to go is to regulate current, not voltage.
It really isn't difficult to wire up a pot to your Arduino and have your Arduino control a transistor through PWM, which on its turn controls the backlight.
You should indeed use that transistor and not wire the backlight directly to an Arduino output as it draws almost five times the current specified for the Arduino per output pin.
Only reason not to do it this way i can think of, is when you have no spare input and/or output available.

Thanks. Because I do not intend to change the LCD backlight after i set it the first time I was hoping to solder in a resistor and be done. I do understand that adding a pot and transistor to the Arduino and them implementing PWM is not terribly difficult, but still it is several more things for me to work through.

I have another question. Both of these claim to be able to dim an LCD backlight via I2C:

Can you tell me if that is a function of the backpack, or a function of the LCD? One of these is selling an LCD and backpack together, but the other is selling just the backpack, so it seems to be a function of the backpack, but I want to be sure.

I have an Adafruit backpack that I have not yet tested and I wonder if that can do LCD dimming.

Thanks!
Mike

It is a function of the backpack for both.
You can see that yourself by reading the documents you are linking to.
These show you how to connect, and you can see that these are simply connected to pins 15 and 16 of a standard LCD .
These pins are the backlight power pins.
The "Hobby Electronics" pcb is shown clearly and shows it uses a Microchip PIC 18F(something) that does the receiving of your commands and controlling the LCD.
Following the traces, you can also see that pin 16 (Cathode of the backlight LED) is controlled (by the PIC processor) through transistor U2.

I made a simple dimmer for LCM1602 IIC. I connect it at the jumber and works good

MikeMoLang:
I would be happy to just put a pot on it and be done, but when I researched that solution I read that it is not the preferred method, and to use a transistor.

I got a bit confused at that point. Can someone please point me in the right direction regarding how to proceed? Is the solution as simple as putting a pot inline at pin 15 or pin 16.

It is indeed as simple as putting a resistor in series with pin 15 or pin 16. You merely have to interrupt that connection between the backpack and the LCD module. The only reason to use a transistor to control it (as there already is in the backpack) is as noted, to provide software control. In fact, you can use PWM in software to continuously and rapidly switch the backlight on and off, but this is not always practical.

If you only want to set and not change the brightness, you just add the resistor. The "setbacklight" function will still turn it on or off.

Alternately, if you want it to be either dim or bright, but never off, you can simply add a resistor between pins 1 and 16 which will set the minimum or "off" brightness.

Just try different resistor values, starting with around 1K.

MikeMoLang:
The problem is that I really want to be able to turn down the backlight brightness and I do not seem to be able to do anything more than turn the backlight on and off using "lcd.setBacklight()". Is this a limitation of the I2C, or the LCD (either? neither?)

Neither. It is a limitation of the h/w on the backpack.
The backpack contains a PCF8574 i2c i/o expander. This allows a host (the Arduino)
to use the i2c bus to control pins on the PCF8574.
One of the PCF8574 i/o pins is hooked up to a transistor that turns the power going to the backlight on or off.

setBacklight(dimvalue) where dimvalue is 0-255 is use to set the brightness
while backlight() and noBacklight() are used to turn the backlight full on/off.

For the h/w on that i2c backpack setBacklight(dimvalue) really doesn't work as setBacklight(dimvalue) is
use to set a brightness and that h/w is not capable of controlling the brightness.
That hardware can only turn the backlight on/off so the library attempts to offer setBacklight() s/w compatibility by
doing the best it can so a dimvalue of zero will turn off the backlight and any other dimvalue
will turn on the backlight since the h/w is unable to actually do any dimming.

--- bill

Hello,

I'm using a NPN transistor for dimming my LCD. I have a PCF8574 I2C interface mounted at the back of a HD44780 LCD. There's a jumper on the back of the two LED pins, remove this jumper. I've connected one LED pin to the the collector pin of the transistor and the other LED pin to the emitter. In my case it doesn't matter which LED pin is connected to a transistor pin, it all works. The transistor's base pin is connected to a Arduino PWM pin. now try using the analogWrite(pinNumber, value) method, for example analogWrite(3, 100), and turn the LCD backlight on, now the backlight will be dimmed! XD

Note: I'm using the LiquidCrystal_I2C library.

there is an easier way :o
I'm using a YmRobot LCM1602 IIC V1 display and I've connected a ppm output from a Leonardo directly to the UPPER pin of the (removed) jumper. See the blue wire.
A pmm value of 10 make the display readable in shadowed conditions; 50 ist linghtish and 150 is bright.

This has deteriorated into another "Try this, try that" thread proliferated by the blind leading the blind.

Why don't you just do what Paul__B recommended and control the LED brightness with a series resistance and be done with it?

Don

thanks for your kind reply.
BECAUSE I'm able to control the brightness in a variable way. It makes (for me) no sense to have a fixed brightness all the time.
comprendre? :smiling_imp:

thanks for your kind reply.
BECAUSE I'm able to control the brightness in a variable way. It makes (for me) no sense to have a fixed brightness all the time.
comprendre?

Thanks for your backhanded complement - but this forum thread is not about you and your desires.

The OP clearly stated more than once that he just wanted to dim the brightness to a certain level and leave it alone after that and Paul told him how to do it.

Don

Here is another Try this then that reply:

There is a jumper on the back of the lcd 20x4. Remove the jumper, put an LDR across the jumper terminals.

Result - When the ambient brightness is bright - sunlight, the display is really bright.

When the ambient light is dark, the display is dark / dim - preventing you blinding yourself.

Hey presto!

I had a similar question as MikeMoLang's. I know this thread is 3 years old but viewers are still reading it. I hope my answer here helps, and I'd appreciate hearing about it. :slight_smile:

I'm prototyping with an Arduino Uno, an Adafruit i2c / SPI character LCD backpack, and an Adafruit Standard LCD 16x2. I'm using i2c mode and the LiquidTWI library. For my configuration, I do not need to do anything with lcd.setBacklight().

The header at LCD pin 16 is the easiest to cut. With a small wire clipper I carefully cut the header pin between pin 16 of the LCD and the backpack, then soldered a wire to pin 16. I connected that wire to pin 3 of the Uno. Any PWM pin will do. I can write any 0<=value<=255 with analogWrite(3, value). A high value makes the backlight dim, a low value makes it bright. The full brightness range and precision of the LCD backlight is usable. With an inline ammeter I carefully measured the maximum current draw on pin 3, and it is 16.7 ma, which is below the rated maximum of each Uno pin (20 ma).

You do not need a transistor to control the backlight of the Adafruit LCD board, which apparently has a good resistor value inline with pin 16. Obviously with other LCDs your mileage may vary. You can measure the current draw of the backlight of your LCD. Make sure you put the positive ammeter lead on the LCD's pin 16 ("ground"), which may seem counter-intuitive. The negative lead of the ammeter goes to ground or Arduino pin 3.

I plan to move this circuit to a Trinket Pro, and it also should have no problem supplying the current.

Cheers,
Matt

mbendaniel:
You do not need a transistor to control the backlight of the Adafruit LCD board, which apparently has a good resistor value inline with pin 16.

In the case of most 1602 LCDs, R8 is "101" or 100 Ohms. R9 is on the other side of the LED and generally 0. Slight possibility they might be exchanged.

This defines about 22 mA which is manageable by an Arduino pin and in fact, is slightly less when switched by an Arduino pin due to its effective 35 Ohm internal resistance.