Categories

Arduino and 2x16 LCD LCM1602 I2C

 

Support LCD 2x16 with Arduino through the I2C interface.

 

Module LM1602 based on PCF8574 popular allows you to connect LCD 2x16, 4x20 or 2x8 to any microcontroller via I2C bus. Through this composition instead of 6 lines (D4, D5, D6, D7, E, RS), we will use only two. Will save valuable output of the Arduino Uno. It is not necessary to connect the potentiometer to adjust the contrast, as it is already on the Board. LM1602 gives us control over the display backlight - we can at any moment turn on and off using the appropriate library functions.

For this project you will need:

 

The previously mentioned library can be downloaded from: https://bitbucket.org/fmalpartida. The downloaded file should be unpacked, and then the entire folder LiquidCrystal put in the Arduino libraries directory (libraries), which is located by default in the Documents folder (the default path on Windows 7: C:/Users/ username/Documents/Arduino/libraries).

 

Downloaded the library has the same name as a standard built into Arduino. So after installing the Arduino software see only the new. In order to return to the standard version, please new folder LiquidCrystal directory from Documents/Arduino/libraries.

 

After installing the library, with the help of wires, connect the module with Arduino as follows:

 

 

LCM1602Arduino Uno
VCC5 V
GNDGND
TrafficA4
SCLA5

 

 

Paste on Wednesday following code:

 

/*
* LCM1602 & Arduino Uno
* VCC - > 5V
* GND - GND
* SCL -> A5
* SDA -> A4
*/

#include // standard Arduino library
#include <LiquidCrystal_I2C.h> // dolaczenie taken library for I2C LCD

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // setting the addresses of a contract for 0x27


void setup()
{
LCD.begin(16,2); // Initialize LCD 2x16

LCD.backlight(); // the following statement podwietlenia
LCD.setCursor(0,0); // sets the cursor at position 0,0 (first row, first column)
LCD.print("Hello, world!");
delay(500);
LCD.setCursor(0,1); //sets the cursor at position 0,0 (second row, first column)
LCD.print("BOTLAND.com.pl");

}

void loop()
{
LCD.backlight(); // the following statement highlighting
delay(5000);
LCD.noBacklight(); // disable highlighting
delay(5000);
}

 

Then wgrywamy code on the plate, and our display will read:

with switching every 5 seconds and lighting.

 

Bibliteki we use is similar to this built into the Arduino environment

  • LCD.setCursor(x,x) - sets the cursor to the specified position in brackets
  • LCD.print("xxxxx") displays the text xxxxx
  • LCD.clear(); - clears the screen
  • In addition,
    • LCD.backlight() - backlight
    • LCD.noBacklight() - backlight off