Backlight and I2C on LCD Display

Hello, I have a backlight enabled LCD that I'm using together with the PCF8574. The wiring and schematics is the same as found in this tutorial from Garagelab, the only difference is the 10k potentiometer that I simply change to a resistor. As in the tutorial, I'm using the LiquidCrystal_I2C library found here. I've noticed that the library has some control for the backlight, however I'm not being able to use it (it changes nothing), am I missing some wiring? Or it may be another problem? The function I'm talking about is the setBacklight(val), it changes nothing. I do believe that the setContrast(val) wouldn't change anything as well, since I'm connecting the contrast pin directly on the GND with a resistor, however I haven't tested it.

Thanks for the help!

Zarnick: Hello, I have a backlight enabled LCD that I'm using together with the PCF8574. The wiring and schematics is the same as found in this tutorial from Garagelab, the only difference is the 10k potentiometer that I simply change to a resistor. As in the tutorial, I'm using the LiquidCrystal_I2C library found here. I've noticed that the library has some control for the backlight, however I'm not being able to use it (it changes nothing), am I missing some wiring? Or it may be another problem? The function I'm talking about is the setBacklight(val), it changes nothing. I do believe that the setContrast(val) wouldn't change anything as well, since I'm connecting the contrast pin directly on the GND with a resistor, however I haven't tested it.

Thanks for the help!

I believe you need another pin to control backlight. you need to define this backlighPin. You also need to use a transistor connected to the pin, and the LCD (A, K)

Something like this?

If yes, how do I set up the Backlight pin on the PCF8574P? Or is it the 7th pin as default?

Thanks.

You are connecting power lines direct to the back light, following that "do it this way and it will magically work" site. (They are actually trying to invoke magic by mentioning it on this particular page). Well, no magic there. You are powering the back light LEDs, so it will light to the intensity set by the resistor you are using for this goal. There is nothing controlling the LEDs from the PCF8574. And there is nothing controlling the contrast either. So your findings are correct.

Most likely controlling the contrast and back light will only work with noticeable difference between the values 0 or any other value. That means any other value will turn it on (100 %), while value 0 will turn it off.

By the way, did you know a potentiometer consists of 2 resistors in the way it is applied here to control the contrast ? It doesn't do what you seem to think it does the way you hacked it.

I take it that the display works but you are looking for away to control back light and contrast ?

Yes, the primary issue would be the backlight, the contrast I'm happy with the resistor solution, but it would also be nice to be able to play with it. I did found one way by connecting a PWM Arduino Pin on the contrast, but this didn't worked for the backlight. What I found odd, was that even if I remove the +5VCC and GND pins that should be for the backlight (pins 15 and 16), the backlight is still on!

Zarnick: Something like this?

If yes, how do I set up the Backlight pin on the PCF8574P? Or is it the 7th pin as default?

Thanks.

yes, you also need a resistor (1k) between pin 7 and the transistor. If you want to control the brightness, simply use PWM. make sure that pin can handle PWM.

My datasheet seems to be incomplete. Which pin is the PWM compatible PCF8574 pin ?

I don't believe anyone is. That's why I used the Arduino Pin for the contrast ;)

@Zarnick: i missed your answer to my first reply. The Fritzing doodle shows PCF pin 7 to be in use for brightness control. As stated before, you need the resistor in the base of the transistor, don't forget that.

If you do want to use that PCF for such functions, it should be able to do something alike, but the PWM would need to be a software solution for this, and be probably at a relatively quite low frequency. Not a thing to use when starting with this matter i'd say.

You need to know exactly what pin the library you are using expects for brightness and contrast control. Sometimes you can set this, also something that should be explained in the libraries documentation.

Ok, I'll try that as soon as I get home!

Thanks for the help!

One thing you can do for brightness control is to have two brightness levels but no OFF. In you schematic, you use a resistor to ground to set the dim brightness. When you turn on P7 of the PCF8574, which turns on the transistor, you will get the bright backlight.

Not PWM for full range of dimming, but it can give you two levels of brightness if you don't ever need to turn off the backlight.

--- bill

Well, unfortunately, nothing I did actually worked! Even taking the pins 15 and 16 off (completely unwiring them on the protoboard) led me no were, the backlight was still on! I'm beginning to think they may be fixed on the pins 1 and 2, since I got this LCD screen already soldered, I mean, I should completely turn the backlight off if I simply got rid of the wires on pin 16 and 15 right?

Zarnick:
Well, unfortunately, nothing I did actually worked! Even taking the pins 15 and 16 off (completely unwiring them on the protoboard) led me no were, the backlight was still on! I’m beginning to think they may be fixed on the pins 1 and 2, since I got this LCD screen already soldered, I mean, I should completely turn the backlight off if I simply got rid of the wires on pin 16 and 15 right?

If the backlight is on when you think pins 15 and 16 are not connected, then you probably are not properly identifying
the pins.

The Tutorial you linked to show pin 1 on the left (nearest to the PCB edge) and the pins increasing to the right (twards the center)
with pin 16 furthest from the edge where pin 1 is.

The schematic you showed in reply #2 is for a different pinout.
It shows pin 15 closest to the PCB edge followed by 16 then 1 and then increasing up to 14 towards the center.

From what I have seen, the pinout in the tutorial is much more common than the one you showed
in reply #2.

— bill

I’m using the pins on the tutorial I showed, were the pins 15 and 16 are the farthest away from the PCB edge. The one I linked the image here was on another web-site, I just used since it was what I was looking for…even if it didn’t helped. But I always used the pins from the tutorial, otherwise I wouldn’t be able to actually use the LCD.

Just to be clear, here's the actual Fritzing sketch.

But that fritzing sketch does not match how you said things were wired. i.e. it shows the backlight wired up.

If you disconnect pins 15 and 16 from the LCD and the backlight is still on, then your LCD uses a pinout that is different from the way you have it wired.

How are you connecting the wires to the actual module? Have you soldered the wires or header to the LCD? I would be better for us to see some actual pictures of your wiring. Make sure that they are clear enough for us to see the wiring and the soldering on the LCD.

Here is what I'd recommend. - Find a datasheet for your LCD and verify the pinout - use a proper contrast circuit (a single resistor to ground is not a proper circuit - use a pot) - Use this library: https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home (Make sure to install it properly, which means removing any other LiquidCrystal_I2C library) I would install it in you local sketchbook/libraries directory and name it "LiquidCrystal" that way it will override the LiquidCrystal library that comes with the IDE. - use the full constructor to specify how you have the PCF8574 wired up.

LiquidCrystal_I2C(i2cAddr, En, Rw, Rs, d4, d5, d6, d7, backlighPin, pol);

If you have it wired up as shown in the fritzing diagram, then your constructor should be:

   LiquidCrystal_I2C(i2cAddr, 4, 5, 6, 0, 1, 2, 3, 7, POSITIVE);

Some of the examples on fm's site and included with the library, are out of date or are for fm's i2c backpack so ignore any code that attempts to use/configure a backlight pin. The constructor specifies all that is needed. You will then initialized and use the LCD the same way as the standard LiquidCrystal library but you will have backlight control using backlight() and noBacklight().

--- bill

I'll try that as soon as possible. But why a resistor to the ground isn't a proper circuit? (really newbie question I know, but hell, I am a newbie ;))

Zarnick: I'll try that as soon as possible. But why a resistor to the ground isn't a proper circuit? (really newbie question I know, but hell, I am a newbie ;))

The Vo input signal (LCD module pin 3) is used to control the contrast of the pixels. You feed that pin a voltage. It isn't an input current that needs to be limited like with an LED. The lower the voltage you provide to the Vo signal, the more intense the pixels will be. To high of a voltage and no pixels show up, to low and all the pixels will be on including the ones that are not supposed to be on. When using a single resistor to ground you are essentially just grounding the pin. Some LCDs will have an acceptable contrast when the Vo signal is grounded but many won't and will simply turn on all the pixels including the ones that should be off. To set the voltage on the Vo signal, you can use a 2 resistor voltage divider between two voltages. The voltage divider will create a voltage that is between the two voltages that is proportionally between the voltages with the same ratio as the ratio of the two resistors. You can either use 2 fixed resistors or pot. A pot allows you to vary the two resistors of the voltage divider to control the output voltage, and that varying voltage is what allows you to adjust the contrast on the LCD.

--- bill

Zarnick: But why a resistor to the ground isn't a proper circuit? (really newbie question I know, but hell, I am a newbie ;))

MAS3: By the way, did you know a potentiometer consists of 2 resistors in the way it is applied here to control the contrast ? It doesn't do what you seem to think it does the way you hacked it.

Ok, so here are the pictures.
I’ve added a trimpot for the contrast (thanks for the tip ;)) and here’s the circuit:

And some closeups:




This is the LCD Pins:

The LCD I’m using a generic GM1602K.

The code I’ve used was this one (with the new library you guys told me about):

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(32,4,5,6,0,1,2,3,7,POSITIVE);  // Set the LCD I2C address
void setup()
{
  // Switch on the backlight
  lcd.begin(16,2);               // initialize the lcd 
  lcd.clear();
  lcd.noBacklight();
  lcd.home ();                   // go home
  lcd.print("Hello, ARDUINO ");  
  lcd.setCursor ( 0, 1 );        // go to the next line
  lcd.print (" WORLD!  ");      
}

void loop()
{

}

And of course, the backlight is still on.
As for who soldered it, I got it already soldered up.