Go Down

Topic: Available LCDs and libraries (Read 4562 times) previous topic - next topic

adwsystems

Jul 20, 2015, 12:31 am Last Edit: Jul 20, 2015, 12:31 am by adwsystems
Just a quick question.

I have used the 16x2 LCDs both direct I/O and via I2C. I see there are some 20x4 LCDs available with the I2C interface. Are the Arduino libraries available to drive these?

groundFungus

#1
Jul 20, 2015, 01:21 am Last Edit: Jul 20, 2015, 01:24 am by groundfungus
Which library did you use for the 16x2?  You might be able to use the same library for the 20x4, just change the begin to (20, 4).  You might also need to change the address and the pin mapping in the constructor depending on the specific LCD module.

adwsystems

I used wire.h and liquidcrystal_I2c.h. There is a line that sets up the LCD for an I2C address, number of rows and columns (LiquidCrystal_I2C lcd(0x27, 16, 2);). So I know hypothetically I can change the values 16 and 2; but I was wondering if anyone had and knew it would work before I spent the money on the LCD.

groundFungus

It has worked for me with 2 different 20x4 LCDs.  I have used the same library for 4 wire 16x2 LCDs as well

.

florinc

Quote
There is a line that sets up the LCD for an I2C address
That's the constructor.

Quote
number of rows and columns (LiquidCrystal_I2C lcd(0x27, 16, 2)
that would be something like
Code: [Select]
 lcd.begin(16, 2);

adwsystems

That's the constructor.
that would be something like
Code: [Select]
lcd.begin(16, 2);


Don't forget we're talking about the I2C version, not the direct I/O version. I had to change lcd.begin(16, 2) to lcd.begin() and add LiquidCrystal_I2C lcd(0x27, 16, 2) to make the I2C version of the 16x2 display work. And it does work. The question before the group is: Does LiquidCrystal_I2C lcd(0x27, 20, 4) work for the 20x4 LCD with the I2C interface?

Paul__B

#6
Jul 20, 2015, 05:04 am Last Edit: Jul 20, 2015, 05:08 am by Paul__B
There is a line that sets up the LCD for an I2C address, number of rows and columns (LiquidCrystal_I2C lcd(0x27, 16, 2).
Well, if that works for an I2C backpack, you are very lucky as you have just by chance happened on a backpack which matches that old library.  Most backpacks currently available will not and you need to use the more detailed constructor with the fmalpartida new-liquidcrystal library.

Other than that, of course the library should function with the 20 x 4 display.  You may need to remember that the third and fourth line are actually extensions of the first and second, though cursor positioning works correctly if you specify within the 20 x 4.

adwsystems

I have found at least 3 different libraries called LiquidCrystal_I2C.h. None of which are on the Arduino site here. Which is the correct one? The best one?

Paul__B

That would be the link I provided.

adwsystems

#9
Jul 22, 2015, 03:14 am Last Edit: Jul 22, 2015, 03:30 am by adwsystems
That would be the link I provided.

Well that library crashed and burned.  I have four 16x2 LCDs that I have purchased over the last 6 months from four different places and none of them work with this library. I am working to determine where I may have gotten the library I have been using. I know it was via a link from the Arduino site here. Anyone have a better library than either the fmalpartida or my current library?

Edit: I found the source of the library I was using. https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library as recommended to me many months ago.

Paul__B

I have four 16x2 LCDs that I have purchased over the last 6 months from four different places and none of them work with this library.
I find that extremely improbable indeed.

I did explain (well, attempted to ... ) that using a given library with the abbreviated three argument descriptor will work only for the backpack which the particular library designer possessed at the time and wrote it for, which presumably explains why you have found an odd library with does work with the short descriptor.

The fmalpartida works with all the available backpack versions, however you need to use the complete descriptor and determine what that correct descriptor is using the I2Cguesser code.

adwsystems

I used Nick Gammon's I2C scanner in addition to the fact that I already knew and had working the displays. The address is 0x27 and the only thing connected to the Arduino UNO (nothing else on the I2C or anywhere else on the Arduino).

After replacing the LiquidCrystal_I2C libraries (including an attempt that involved uninstalling the Arduino IDE, deleting the libraries, and then reinstalling the IDE and adding and adding in the new library). I used the example code straight from the website, just changing the address (from 0x38 to 0x27)

Code: [Select]
#include <Wire.h>
#include <LiquidCrystal_I2C.h>


#define BACKLIGHT_PIN     13

LiquidCrystal_I2C lcd(0x27);  // Set the LCD I2C address


// Creat a set of new characters
const uint8_t charBitmap[][8] = {
   { 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
   { 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
   { 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
   { 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
   { 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
   { 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
   { 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
   { 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }
   
};

void setup()
{
   int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));

  // Switch on the backlight
  pinMode ( BACKLIGHT_PIN, OUTPUT );
  digitalWrite ( BACKLIGHT_PIN, HIGH );
 
  lcd.begin(16,2);               // initialize the lcd

   for ( int i = 0; i < charBitmapSize; i++ )
   {
      lcd.createChar ( i, (uint8_t *)charBitmap[i] );
   }

  lcd.home ();                   // go home
  lcd.print("Hello, ARDUINO "); 
  lcd.setCursor ( 0, 1 );        // go to the next line
  lcd.print (" FORUM - fm   ");
  delay ( 1000 );
}

void loop()
{
   lcd.home ();
   // Do a little animation by writing to the same location
   for ( int i = 0; i < 2; i++ )
   {
      for ( int j = 0; j < 16; j++ )
      {
         lcd.print (char(random(7)));
      }
      lcd.setCursor ( 0, 1 );
   }
   delay (200);
}


It did not work, blank screen with lots of flickering. One of the displays I am using is http://www.dfrobot.com/index.php?route=product/product&product_id=135&search=lcd+iic&description=true#.Va-zhflViko

One conspicuous item about the fm library is the inclusion of the backlight pin. I don't have any serial enabled LCDs that have or require a output/input to drive the backlight. Many of the serial (I2C) LCDs I looked at do not have a pin for that. I would hope the library can handle that, but since I didn't write the library I don't know.

If it should work, what do I have to do to make it work? Being the link to the fm library is on the arduino site (opposed to being from a forum post), I would to prefer to use it.

chucktodd

I used Nick Gammon's I2C scanner in addition to the fact that I already knew and had working the displays. The address is 0x27 and the only thing connected to the Arduino UNO (nothing else on the I2C or anywhere else on the Arduino).


If it should work, what do I have to do to make it work? Being the link to the fm library is on the arduino site (opposed to being from a forum post), I would to prefer to use it.
what is the chip connected to the LCD? a TCA9434, PCF8574? MCP23008? MCP23017?

the library need to be written for the correct I2C expander.

Chuck.
Currently built mega http server, Now converting it to ESP32.

adwsystems

#13
Jul 22, 2015, 06:42 pm Last Edit: Jul 23, 2015, 01:43 am by adwsystems
If I remember correctly a PCF8574, maybe an PCF8574A (is that an option?). I would need to double check at home tonight. Along those lines, the chip pinout would also have to match the library.

Edit: It is a PCF8574T chip.

chucktodd

If I remember correctly a PCF8574, maybe an PCF8574A (is that an option?). I would need to double check at home tonight. Along those lines, the chip pinout would also have to match the library.
trace out the wiring from LCD module to the IO Expander.  The fdebrabander Arduino-LiquidCrystal-I2C-library uses these defaults for defining how the module is wired.
the LCD databus is connected in 4bit mode using P4..P7, RS = P0, Rw=P1, En=P2, backlight = P3.
This must match your module. Else change the defines in your library.

Code: [Select]


// flags for backlight control
#define LCD_BACKLIGHT 0x08
#define LCD_NOBACKLIGHT 0x00

#define En B00000100  // Enable bit
#define Rw B00000010  // Read/Write bit
#define Rs B00000001  // Register select bit


chuck.
Currently built mega http server, Now converting it to ESP32.

Go Up