Description
With this IIC/I2C/TWI/SP-Interface for Arduino module, hence, you will be able to realize data display via only 2 wires. If you already have I2C devices in your project, most of all, this LCD module actually cost no more resources at all.
IIC/I2C/TWI/SP-Interface for Arduino Compatibility
1602 LCD and also 2004 LCD
Most noteworthy, this interface is only for Character Displays. Not suitable with Graphics Displays.
Features
I2C Address: 0X20~0X27 (the original address is 0X20,you can change it yourself) Supply voltage: 5V The backlight and contrast is adjusted by potentiometer Come with 2 IIC interface, which can be connected by Dupont Line or IIC dedicated cable (cable not included)
Code
/* TechDepot.co test code for 2004A LCD with backpack interface labelled “YwRobot Arduino LCM1602 IIC V1” Or displays with backpack interface labelled “A0 A1 A2” */
#include <Wire.h> // Called from Arduino IDE
/* You need the NewLiquidCrystal Library, you can download the latest version from: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads Make sure to either delete or move any other Liquid Crystal library you currently have Check the Library “utility/docs” for commands details and extra information. */
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD(I2C_addr, en,rw,rs,d4,d5,d6,d7,bl,blpol)
void setup() // Runs only once on program start { Serial.begin(9600); // Set the serial connection speed for the Serial Monitor, make sure to set the same speed in Serial Monitor
lcd.begin(20,4); // Initialize the lcd for 20 chars 4 lines display and turn on backlight
//lcd.backlight(); // Use this any time to turn backlight on //lcd.noBacklight(); // Use this any time to turn backlight off
// To write on the display you need to set the cursor position (Char pos, Line no) // Char pos can be any where between 0 -> 19, Line no 0 -> 3
lcd.setCursor(4,0); // Start at character 5 on line 0 lcd.print(“Hello There!”); delay(1000); lcd.setCursor(0,1); // Start at line 1 very start (pos 0) lcd.print(“Hi From TechDepot.co”); delay(1000); lcd.setCursor(0,2); // Start at line 2 very start (pos 0) lcd.print(“20 by 4 Line Display”); delay(1000); lcd.setCursor(2,3); // Start at character 3 on line 3 lcd.print(“www.TechDepot.co”); delay(10000); lcd.clear(); // Clear the whole screen lcd.setCursor(2,0); lcd.print(“Now type & send”); lcd.setCursor(0,1); lcd.print(“from Serial Monitor.”); // Make sure to set your Serial monitor “No line ending” & “9600 baud” }
void loop() { { // Wait tell text is received from Serial Monitor if (Serial.available()) { delay(100); // wait a bit for the entire message to arrive lcd.clear(); // Clear the whole screen // Read the complete message while (Serial.available() > 0) { lcd.write(Serial.read()); // Write the text to display } } }
}