dinsdag 23 augustus 2016

Arduino 1602A LCD with I2C

Made LCD 1602A with I2C interface working with Arduino after using the Arduino LCD shield for some tests. The disadvantages of the Arduino LCD shield are that it uses s lot of the Arduino IO pins and fitting it in a nice box can give some problems with nthe IO connections.
The module LCD1602A with an 16x2 display i received from China had a separate I2C interface module, so i soldered them first together.
There are several discussions and misinterpretations about this module. I hope this post will help some people.
It took me time than expected to get the module up and running. The problems where more hardware than software related. The article  http://forum.arduino.cc/index.php?topic=128635.0 on the Arduino forum helped me a lot.
Here is how i finally got my LCD display working:

Connect GND, VCC, SDA and SCL to the corresponding connections GND, VCC, SDA and SCL on the Arduino Uno. I did not connect them to the analog input lines as suggested.

Use an I2C scan program to find the address of the LCD and write it down as you will need this in the next program. This I2C scan program worked for me and gave (on the console) the address

Program to scan I2C

Console / serial monitor

Test the LCD with a program where, if needed, the I2C address is modified to the address found with the I2C scan program. This part was the most difficult. Sometimes adding libraries was needed, and even after this some additional libraries where also needed. Step one in the article on the Arduino forum also suggested downloading and renaming a library.
Sometimes i observed reactions of the LCD (blinking/ flashing). Getting characters on the LCD screen did not work. I tested several programs.
The real problem was the contrast of the pixels on the LCD. You can change the pixel contrast by inserting a screwdriver into the pot meter ( potentiometer ) at the back and turning it.
For me the setting of the pot meter was the most critical step. Characters are visible only in a very small range.
The pot meter is for the pixel contrast. The pot meter is NOT for the back-light !
I already had played with this pot meter using some of the LCD programs but without success. The program where i had luck was written for a 4 x 20 display. I only had modified the I2C address in the program and suddenly during slow turning the pot meter i had my output.
After this i modified the program for a 2 x 16 character output:

Program to test LCD (2*16)


It should be possible to change the I2C address using the A0 A1 A2 pins on the I2C interface. This way you can connect multiple displays.
I did not test this (yet).

Geen opmerkingen: