i2c comunication with an LCD
1.
2.
3.
4.
5.
6.
Intro!
Since the use of an LCD requires many microcontroller pins, we will reduce that number using serial communication, which is basically sending "packages" of data one after another, using only two pins of our microcontroller , pins SDA and SCL which are the analog pins A4 and A5 of the Arduino NANO or pro mini.
Schematic!
Connections!
First of all we connect i2c pins module as shown in the schematic. Power the LCD module to 5 volts and connect the ground as well. The SDA pin of the i2c module conected to arduinio A5 and the SCL pin to A4. We connect the arduino to USB and we are ready to program. In order to make the LCD work we need to inport the LCD library for arduino.
You can download the
To install it we just go to Program -> inport library and we open the .zip file that we've just downloaded.
Code!
/* http://www.electronoobs.com */
/*-----( Inport library )-----*/
#include <
#include <
//i2c pins
void
{
//WE define our LCD 16 columns and 2 rows
lcd.
lcd.backlight();//Power on the back light
//lcd.backlight(); Power off the back light
}
void
{
//Write your text:
lcd.setCursor(0,0); //we start writing from the first row first column
lcd.
lcd.setCursor(0,1);
lcd.
lcd.clear();//Clean the screen
lcd.setCursor(0,0);
lcd.
lcd.setCursor(0,1);
lcd.
}
See other tutorial here: