[SOLVED] I2C LCD - Setup instructions for 16x2

blackscience, have a look at this topic http://arduino.cc/forum/index.php/topic,94633.msg710615.html#msg710615%20(http://arduino.cc/forum/index.php/topic,94633.msg710615.html#msg710615. May help you.

Pavilion1984. Thanks alot mate, i managed to solve the issue yesterday evening using the exact same method :slight_smile: nice to know my solution wasnt a bad idea as i am new to all of this. I thought i was going to have to modify some of the libraries which looked rather daunting.

 threshold = analogRead (pinA0Value);   // read value of A0

  if (threshold<=999 && threshold>=100) { 
      lcd.setCursor (3,1);        // go to start of the second line - 4th char
      lcd.print("    ");           // clear out the thousands char as it is no longer needed
  
  }else if (threshold<=99 && threshold>=10) {
      lcd.setCursor (2,1);        // go to start of the second line - 3rd char
      lcd.print("     ");         // clear out the hundreds char as it is no longer needed

  }else if (threshold<=9 && threshold >=0) {
      lcd.setCursor (1,1);        // go to start of the second line - 2nd char
      lcd.print("      ");        // clear out the tens char as it is no longer needed
  }
  
  lcd.setCursor (0,1);        // go to start of 2nd line
  lcd.print(threshold, DEC);  // print the threshold value

blackscience. No problem, happy to help.

Thanks for these clear instructions, I am sure they will help, but I afraid that I have got stuck on the first step "Rename the existing library" (or words to that effect).

After years using a PC I am sure that I could do it there, but not on my newish iMac!

If I rename the folders there, the IDE still picks up the old library. Any ideas anyone?

Thanks in advance

:stuck_out_tongue_closed_eyes:

OK, it is done, if anyone out there is trying to help with my MAC query, thanks but somehow I've stumbled on a solution. The LCD now works fine.

And thanks for the original post, could not be more clear.

I'm glad you all found it useful - I also spent evenings banging my head against a wall trying to solve this.
:slight_smile:

@ianbren - nice post there, here is a bit of karma for you!

I am glad that you like the library and find it useful.

Awesome stuff. Great help.

Many thanks to ianbren. I was stuck with some lcds due to wrong i2c address. Your instructions are clear and comprehensive. Good job.

That was extremely helpful, thanks ianbren !

Just a few pointers for newbies like me (please feel free to correct me) :

  • My LCD setup had PCF8574T chip as the 8-bit I/O expander for I2C bus. (Address 0x27).
  • 8 pins from PCF8574T connect to the LCD display as follows (in this model of the board) :
    LCD <------> pcf8574T CHIP
    RS(pin4) - P0 (pin4)
    RW(pin5) - P1 (pin5)
    EN(pin6) - P2 (pin6)
    BL(pin3) - P3 (pin7)
    D4(pin11) - P4 (pin9)
    D5(pin12) - P5 (pin10)
    D6(pin13) - P6 (pin11)
    D7(pin14) - P7 (pin12)

So, for example, in the code:
#define En_pin 2
means EN signal of LCD is being addressed by P2 of the 8 bit (P0-P7) address bus (parallel).

  • The PCF8574T details are here - PCF8574/74A | NXP Semiconductors (datasheet is a must read).
  • My i2c 1602 blue lcd display has a 2-pin jumper which says BLK and VCC. Removing the jumper enabled the code to take control of the back-light. (otherwise the backlight is always on).
  • On my MAC, I right clicked on the Arduino application file, and selected "Show Package Contents". Then looked in Contents->Resources->Java->libraries. Renamed LiquidCrystal to "LiquidCrystal.DonotUse.ignoreWarning". When I restart Arduino, I get warning that the LiquidCrystal.DonotUse.ignoreWarning library cannot be used and I just ignore the warning. This way, I get a reminder that I'm using a external library for LiquidCrystal. I just downloaded the excellent fmalpartida's LiquidCrystal_V1.2.1.zip (to my Downloads folder). Then from Arduino application, I did a Sketch->"Import Library"->"Add library" and selected the LiquidCrystal_V1.2.1.zip file. That's all. The library got installed under my "Documents/Arduino/Libraries" as a folder called LiquidCrystal .
  • tip: don't skip the address scanner step!

i've got my i2c backpacked LCD (PCF8574-based one from ebay, like the Sainsmart or YFRobot ones) working with my Mega2560r3 using the newLiquidCrystal library but does anyone know how to get them working with the LiquidCrystal_I2C library?

The reason I'd prefer the LiquidCrystal_I2C version is that there is a modified version that works with the ATtiny85 on the Playground by the author of TinyWireM, although I can't get it to work either.

If I could get it to work on the Mega, I think I could get it to work on the Tiny, although I'm not convinced TinyWireM actually works with IDE 1.0+ anyway, I've already wasted 2 days fighting with it!

It does seem odd that there are so many LiquidCrystal libraries floating about and pretty much the only one that works with the HD44780 with or without I2C is newLiquidCrystal! I had the same problem with the Raspberry Pi, I modified the Adafruit library to work with that (no I2C) after trying about five different ones.

sej7278,
To me, it sounds like the answer needs to be to get fm's code working with TinyWireM rather than
the other way around.

I'll take a look and see what it would take.
I've taken a quick look at the USli2c library. It is unfortunate that the library object
was named TinyWireM rather than Wire but that can be handled with some clever #defines

It shouldn't be that difficult. The pain is that since it is different library and the STUPID! ide
doesn't automatically set up include paths to the libraries, the user sketch will have
to include the proper wire library <Wire.h> or <TineWireM.h> and if the user
wants a sketch that "just works" on any hardware ifdefs will be needed and the STUPID! ide
is too wimpy to understand ifdefs so I'm not sure it will work.

--- bill

bperrybap:
sej7278,
To me, it sounds like the answer needs to be to get fm's code working with TinyWireM rather than
the other way around.

yes i had a go at getting it sorted but ended up with a mess of trying to rename all the Wire calls to TinyWireM ones, its not very portable that way, the author makes use of a bunch of ifdefs when he tried to make it work with the older LiquidCrystal library:

#if defined(__AVR_ATtiny85__) || (__AVR_ATtiny2313__)
#include "TinyWireM.h"      // include this if ATtiny85 or ATtiny2313
#else 
#include <Wire.h>           // original lib include
#endif

i also tried patching the latest arduino-mk so i could do without that god-awful ide but didn't get very far, there's still a lot of hardcoding in there.

sej7278:
yes i had a go at getting it sorted but ended up with a mess of trying to rename all the Wire calls to TinyWireM ones, its not very portable that way.

The key is not to rename anything in the code but rather use macros to do it for your.
i.e. things like:
#define Wire TinyWireM

--- bill

Thanks ianben. I wished I Iooked here first... would have saved me a few hours of frustration.
The vendor gave me the wrong I2c address and wrong version of library code.
I have a serial LCD from another vendor that I have been using for awhile and I thought this I2c module would be a snap to configure.
I was wrong.

Just posting to say thanks to Ian for the excellent guide on this, and also to fm for creating the library in the first place!

I would just like to echo the sentiment of jessesteinen, and thank fm and Ian for making the process of getting a i2C LCD up and going child's play. Thanks also to Krodal who as far as I can see, wrote the I2C scanner code originally.

Pedro.

Hello!

I´m Getting Crazy with my I2C LCD

I have just bought a 20X4 LCD but when I want to transfer the software to arduino I always have the same problem.

compilation error

C:\Users\Documents\Arduino\libraries\LiquidCrystal_I2C\LiquidCrystal_I2C.cpp:248: error: 'delayMicroseconds' was not declared in this scope

I have follow all the steps of this post. and more examples of all arrown the web but nothing works.

Robo_proyect,
Please start a new thread for your issue.
--- bill

Thank you so much. XD